Skip to content

Commit cef76e8

Browse files
Merge pull request #453 from rpodishe/OSD-28972-automated-dependency-bumps
OSD-28972: Updated github actions workflow to support dependabot PRs
2 parents b1691b0 + 830d2bc commit cef76e8

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed
Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,51 @@
11
name: Auto tidy interceptor after cadctl changes
22

33
on:
4-
pull_request:
4+
pull_request_target:
5+
types: [opened, synchronize]
56
paths:
67
- 'go.mod'
78
- 'go.sum'
89
- '**/*.go'
910
- '!interceptor/**'
1011

12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
1116
jobs:
1217
tidy:
1318
runs-on: ubuntu-latest
1419

1520
steps:
16-
- name: Checkout the repository
21+
- name: Checkout PR branch
1722
uses: actions/checkout@v4
1823
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 }}
2027

2128
- name: Set up Go
2229
uses: actions/setup-go@v5
2330
with:
24-
go-version: 'stable'
31+
go-version: stable
2532

2633
- name: Run go mod tidy in interceptor
2734
working-directory: interceptor
35+
run: go mod tidy
36+
37+
- name: Check for changes when run go mod tidy in interceptor
38+
id: diffcheck
2839
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
3744
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"

0 commit comments

Comments
 (0)