-
Notifications
You must be signed in to change notification settings - Fork 11
55 lines (47 loc) · 1.78 KB
/
fix-lint.yml
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
name: Autofix Linting
on:
issue_comment:
types: [created]
# Down scope as necessary via https://docs.github.com/en/actions/security-guides/automatic-token-authentication#modifying-the-permissions-for-the-github_token
permissions:
checks: write
contents: write
pull-requests: write
jobs:
run-linters:
name: Run linters
if: github.event.issue.pull_request && ${{ github.event.comment.body == '!fix' }}
runs-on: ubuntu-latest
steps:
- name: GetBranch
id: 'get-branch'
run: echo ::set-output name=branch::$(gh pr view $PR_NO --repo $REPO --json headRefName --jq '.headRefName')
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check out Git repository
uses: actions/checkout@v3
with:
ref: ${{ steps.get-branch.outputs.branch }}
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Lint
run: |
forge fmt
pwd
if [[ `git diff --exit-code` ]]; then
git config --local user.name 'GitHub Actions Bot'
git config --local user.email '<>'
git add .
git commit -m "Github Actions automatically updated formatting with forge fmt"
COMMIT_HASH=$(git rev-parse HEAD)
echo "# Github Actions automatically updated formatting with forge fmt\n$COMMIT_HASH" >> .git-blame-ignore-revs
git add .git-blame-ignore-revs
git commit -m "Updated .git-blame-ignore-revs with commit $COMMIT_HASH"
BRANCH_NAME=$(git symbolic-ref --short HEAD)
git push origin $BRANCH_NAME
fi
id: update