-
Notifications
You must be signed in to change notification settings - Fork 3
62 lines (53 loc) · 1.49 KB
/
go-auto-format.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
56
57
58
59
60
61
62
name: Go Format and Check
on:
push:
branches: [develop]
pull_request:
branches: "**"
permissions:
pull-requests: write
contents: write
jobs:
format-and-check:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Install govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest
- name: Configure Git
run: |
git fetch -q
git checkout ${{github.head_ref}} --progress
git config --global user.name 'Dark Relics Automatic'
git config --global user.email '[email protected]'
git pull
- name: Format and check code
run: |
for dir in core ssh_server; do
cd ./$dir
echo "Processing $dir directory"
go fmt ./...
go mod tidy
go vet ./...
govulncheck ./...
cd ..
done
- name: Check for changes
id: git-check
run: |
git add . -v
if git diff-index --quiet HEAD; then
echo "changes=false" >> $GITHUB_OUTPUT
else
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
if: steps.git-check.outputs.changes == 'true'
run: |
git commit -m "Apply formatting and update dependencies" --allow-empty
git push -v