-
Notifications
You must be signed in to change notification settings - Fork 4
49 lines (47 loc) · 1.49 KB
/
pre_commit.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
name: Run pre-commit checks
on:
push:
pull_request:
types: [opened, synchronize, reopened]
jobs:
run-pre-commit:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go environment
uses: actions/[email protected]
with:
go-version-file: "go.mod"
- name: Install Pre-Commit
run: pip install pre-commit
- name: Install dependencies
run: |
# install required go packages
go mod tidy
# install gofumpt
go install mvdan.cc/gofumpt@latest
# install golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
- name: Autoupdate hooks
run: pre-commit autoupdate
- name: Run pre-commit
uses: pre-commit/[email protected]
env:
SKIP: "no-commit-to-branch" # if not skipped, will always fail on main
- name: Push changes
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add .
if git diff-index --quiet HEAD; then
echo "No changes were made"
exit 0
fi
echo "Found changes"
git commit -m "chore: automatically push pre-commit changes"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: always()