-
Notifications
You must be signed in to change notification settings - Fork 2
60 lines (50 loc) · 1.84 KB
/
lint.yaml
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Lint
on:
pull_request:
env:
GIT_USERNAME: ${{ github.actor }}
GIT_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
FIX_COMMIT_MESSAGE: Fixed /hook_tools/lint.py lints
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
submodules: true
- name: Pull container
run: ./utils/lint --only-pull-image
- name: Lint
run: |
git show ${{ github.event.pull_request.head.sha }} --format=%s --no-patch --no-color
if [[ "$(git show ${{ github.event.pull_request.head.sha }} --format=%s --no-patch --no-color)" == "${{ env.FIX_COMMIT_MESSAGE }}" ]]; then
# The previous commit is a lint-fix commit, do not attempt to
# re-run the linter.
./utils/lint \
--command-name="utils/lint" \
--diagnostics-output=github \
validate --all
exit 0
fi
./utils/lint \
--command-name="utils/lint" \
--diagnostics-output=github \
fix --all && exit 0 || true
# The linter was able to find some fixable things.
# Authenticate with GitHub.
git config --global user.name "${{ env.GIT_USERNAME }}"
git config --global user.email "${{ env.GIT_USERNAME }}@users.noreply.github.com"
cat <<- EOF > $HOME/.netrc
machine github.com
login ${{ env.GIT_USERNAME }}
password ${{ env.GIT_PASSWORD }}
machine api.github.com
login ${{ env.GIT_USERNAME }}
password ${{ env.GIT_PASSWORD }}
EOF
chmod 600 $HOME/.netrc
# Now push that commit to the source branch.
git commit -am "${{ env.FIX_COMMIT_MESSAGE }}"
git push origin HEAD:${{ github.head_ref }}