blob: 92dbd7abe145a16bfb49ee1d124cb278ca43e977 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
name: format
on: [push, pull_request]
jobs:
format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Dependencies
run: |
sudo apt -q update
sudo apt install -q -y clang-format-6.0
- name: Check
run: |
if [[ -n "${GITHUB_BASE_REF}" ]]; then
# pull request, check head branch against base branch
GITHUB_BEFORE="$(git ls-remote origin "${GITHUB_BASE_REF}" | cut -f1)"
elif [[ "${GITHUB_REF}" != "refs/heads/master" ]]; then
# workflow triggered from some branch other than master, assume that
# the branch will eventually be merged into master
GITHUB_BEFORE="$(git ls-remote origin refs/heads/master | cut -f1)"
else
# master branch, compare against previous state
# (jq comes preinstalled on github runners)
GITHUB_BEFORE="$(jq -r '.before' "${GITHUB_EVENT_PATH}")"
fi
# github interleaves stderr and stdout, redirect everything to stdout
/bin/bash -eu build-aux/ci/format-code.sh "${GITHUB_BEFORE}..${GITHUB_SHA}" 2>&1
|