Skip to content

Commit 043a09e

Browse files
committed
ci: add workflow for automatic dependency updates
1 parent 8491488 commit 043a09e

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

.github/workflows/update-deps.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Update Dependencies
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
paths:
7+
- 'go.mod'
8+
- 'go.sum'
9+
push:
10+
branches:
11+
- main
12+
paths:
13+
- 'go.mod'
14+
- 'go.sum'
15+
16+
jobs:
17+
update-deps:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
pull-requests: write
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
ref: ${{ github.head_ref }}
28+
29+
- name: Set up Go
30+
uses: actions/setup-go@v5
31+
with:
32+
go-version: '1.21'
33+
cache: true
34+
35+
- name: Run go mod tidy
36+
run: go mod tidy
37+
38+
- name: Check for changes
39+
id: git-check
40+
run: |
41+
if [[ -n $(git status --porcelain) ]]; then
42+
echo "changes=true" >> $GITHUB_OUTPUT
43+
else
44+
echo "changes=false" >> $GITHUB_OUTPUT
45+
fi
46+
47+
- name: Commit and push if changed
48+
if: steps.git-check.outputs.changes == 'true'
49+
run: |
50+
git config --global user.name 'github-actions[bot]'
51+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
52+
git add go.mod go.sum
53+
git commit -m "chore(deps): update dependencies with go mod tidy"
54+
git push

0 commit comments

Comments
 (0)