-
Notifications
You must be signed in to change notification settings - Fork 3
74 lines (58 loc) · 1.88 KB
/
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
63
64
65
66
67
68
69
70
71
72
73
name: Format
on:
push:
pull_request:
jobs:
report:
runs-on: ubuntu-latest
steps:
- name: Set Git Config
run: |
git config --global user.name 'James Adair'
git config --global user.email 'jmsadair@gmail.com'
- name: Install clang-format
run: sudo apt install -y clang-format
- name: Checkout code
uses: actions/checkout@v4
- name: Format .proto files
run: clang-format -i internal/protobuf/*.proto
- name: Check for modified .proto files
id: git-check-1
run: |
if [[ $(git diff --name-only) == *".proto"* ]]; then
echo "MODIFIED=true" >> $GITHUB_OUTPUT
else
echo "MODIFIED=false" >> $GITHUB_OUTPUT
fi
- name: Check output
run: echo "Modified is ${{ steps.git-check-1.outputs.MODIFIED }}"
- name: Commit clang-format changes
if: steps.git-check-1.outputs.MODIFIED == 'true'
run: |
git commit -am "Committing clang-format changes"
git push
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
- name: Install gofumpt
run: go install mvdan.cc/gofumpt@latest
- name: Install golines
run: go install github.com/segmentio/golines@latest
- name: Format Go code
run: gofumpt -l -w .
- name: Fix line length
run: golines -w .
- name: Check for modified .go files
id: git-check-2
run: |
if [[ $(git diff --name-only) == *".go"* ]]; then
echo "MODIFIED=true" >> $GITHUB_OUTPUT
else
echo "MODIFIED=false" >> $GITHUB_OUTPUT
fi
- name: Commit go fmt changes
if: steps.git-check-2.outputs.MODIFIED == 'true'
run: |
git commit -am "Committing go fmt changes"
git push