File tree Expand file tree Collapse file tree 1 file changed +26
-12
lines changed Expand file tree Collapse file tree 1 file changed +26
-12
lines changed Original file line number Diff line number Diff line change 1
1
name : Auto tidy interceptor after cadctl changes
2
2
3
3
on :
4
- pull_request :
4
+ pull_request_target :
5
+ types : [opened, synchronize]
5
6
paths :
6
7
- ' go.mod'
7
8
- ' go.sum'
8
9
- ' **/*.go'
9
10
- ' !interceptor/**'
10
11
12
+ permissions :
13
+ contents : write
14
+ pull-requests : write
15
+
11
16
jobs :
12
17
tidy :
13
18
runs-on : ubuntu-latest
14
19
15
20
steps :
16
- - name : Checkout the repository
21
+ - name : Checkout PR branch
17
22
uses : actions/checkout@v4
18
23
with :
19
- fetch-depth : 0
24
+ ref : ${{ github.event.pull_request.head.ref }}
25
+ repository : ${{ github.event.pull_request.head.repo.full_name }}
26
+ token : ${{ secrets.GITHUB_TOKEN }}
20
27
21
28
- name : Set up Go
22
29
uses : actions/setup-go@v5
23
30
with :
24
- go-version : ' stable'
31
+ go-version : stable
25
32
26
33
- name : Run go mod tidy in interceptor
27
34
working-directory : interceptor
35
+ run : go mod tidy
36
+
37
+ - name : Check for changes when run go mod tidy in interceptor
38
+ id : diffcheck
28
39
run : |
29
- go mod tidy
30
- git diff
31
- if [[ -n "$(git status --porcelain)" ]]; then
32
- git config user.name "github-actions[bot]"
33
- git config user.email "github-actions[bot]@users.noreply.github.com"
34
- git add go.mod go.sum
35
- git commit -m "On PR: tidy interceptor go.mod after cadctl go.mod update"
36
- git push
40
+ if [[ -n "$(git status --porcelain interceptor/go.mod interceptor/go.sum)" ]]; then
41
+ echo "changes=true" >> $GITHUB_OUTPUT
42
+ else
43
+ echo "changes=false" >> $GITHUB_OUTPUT
37
44
fi
45
+
46
+ - name : Commit and push if there are changes
47
+ if : steps.diffcheck.outputs.changes == 'true'
48
+ uses : EndBug/add-and-commit@v9
49
+ with :
50
+ message : " On PR: tidy interceptor go.mod after cadctl go.mod update"
51
+ add : " interceptor/go.mod interceptor/go.sum"
You can’t perform that action at this time.
0 commit comments