Skip to content

Commit bc5898c

Browse files
committed
[BUILD] Upgrade go dependencies using a custom github action
1 parent e659d88 commit bc5898c

File tree

3 files changed

+101
-24
lines changed

3 files changed

+101
-24
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Update Go Dependencies
2+
3+
on:
4+
schedule:
5+
# Run every Monday at 9:00 AM UTC
6+
- cron: '0 9 * * 1'
7+
workflow_dispatch: # Allow manual trigger
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
update-dependencies:
15+
name: Update Go Dependencies
16+
runs-on: ubuntu-24.04
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v5
21+
with:
22+
ref: master
23+
fetch-depth: 0
24+
25+
- name: Set up Go
26+
uses: actions/setup-go@v6
27+
with:
28+
go-version: '1.25'
29+
30+
- name: Update Go dependencies
31+
run: make update-go-deps
32+
33+
- name: Tidy dependencies
34+
run: make tidy
35+
36+
- name: Generate manifests
37+
run: make generate manifests
38+
39+
- name: Format and lint fix
40+
run: make fmt lint-fix
41+
42+
- name: Check for changes
43+
id: check_changes
44+
run: |
45+
if [ -n "$(git status --porcelain)" ]; then
46+
echo "has_changes=true" >> $GITHUB_OUTPUT
47+
else
48+
echo "has_changes=false" >> $GITHUB_OUTPUT
49+
fi
50+
51+
- name: Create Pull Request
52+
if: steps.check_changes.outputs.has_changes == 'true'
53+
uses: peter-evans/create-pull-request@v7
54+
with:
55+
token: ${{ secrets.PAT }}
56+
commit-message: 'chore(deps): update Go dependencies'
57+
title: 'chore(deps): update Go dependencies'
58+
body: |
59+
## Automated Go Dependencies Update
60+
61+
This PR updates Go module dependencies to their latest versions.
62+
63+
### Changes made:
64+
- Updated Go module dependencies via `make update-go-deps`
65+
- Regenerated manifests via `make generate manifests`
66+
- Applied formatting and linting fixes via `make fmt lint-fix`
67+
68+
Please review the changes and ensure all tests pass before merging.
69+
branch: automated/update-go-deps
70+
delete-branch: true
71+
labels: |
72+
dependencies
73+
go
74+
automated
75+

Makefile

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,20 +294,32 @@ release: check-release ## Tag and push a release.
294294
git tag -a ${REL_TAG} -m ${RELEASE_MSG}
295295
git push origin ${REL_TAG}
296296

297+
define update-module-deps
298+
echo "Updating $(1) deps"; \
299+
cd $(1); \
300+
go mod tidy; \
301+
for m in $$(go list -mod=readonly -m -f '{{ if and (not .Replace) (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
302+
go get -u $$m; \
303+
done; \
304+
go mod tidy
305+
endef
306+
297307
update-go-deps: ## Update Go modules dependencies.
298-
@echo "Finding all directories with go.mod files..."
299-
@for gomod in $$(find . -name "go.mod" | sort); do \
308+
@echo "Updating third_party modules first (deepest to shallowest)..."
309+
@for gomod in $$(find ./third_party -name "go.mod" 2>/dev/null | awk '{print length, $$0}' | sort -rn | cut -d' ' -f2-); do \
300310
dir=$$(dirname $$gomod); \
301-
( \
302-
echo "Updating $$dir deps"; \
303-
cd $$dir; \
304-
go mod tidy; \
305-
for m in $$(go list -mod=readonly -m -f '{{ if and (not .Replace) (not .Indirect) (not .Main)}}{{.Path}}{{end}}' all); do \
306-
go get -u $$m; \
307-
done; \
308-
go mod tidy \
309-
) \
311+
($(call update-module-deps,$$dir)); \
310312
done
313+
@echo "Updating properties, api, and root modules..."
314+
@for dir in ./properties ./api .; do \
315+
if [ -f $$dir/go.mod ]; then \
316+
($(call update-module-deps,$$dir)); \
317+
fi \
318+
done
319+
@echo "Updating tests/e2e module last..."
320+
@if [ -f ./tests/e2e/go.mod ]; then \
321+
($(call update-module-deps,./tests/e2e)); \
322+
fi
311323

312324
tidy: ## Run go mod tidy in all Go modules.
313325
@echo "Finding all directories with go.mod files..."

renovate.json

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414
"docker:enableMajor",
1515
"group:allDigest"
1616
],
17-
"postUpdateOptions": [
18-
"gomodTidy",
19-
"gomodUpdateImportPaths"
20-
],
17+
2118
"customManagers": [
2219
{
2320
"customType": "regex",
@@ -36,8 +33,8 @@
3633
"matchManagers": [
3734
"gomod"
3835
],
39-
"rangeStrategy": "replace",
40-
"description": "Prevent downgrades for all Go modules - only allow upgrades"
36+
"enabled": false,
37+
"description": "Disable Go module updates - handled by automated workflow: .github/workflows/update-go-deps.yml"
4138
},
4239
{
4340
"matchCategories": [
@@ -52,7 +49,6 @@
5249
"major"
5350
],
5451
"matchManagers": [
55-
"gomod",
5652
"github-actions",
5753
"maven",
5854
"dockerfile",
@@ -70,7 +66,6 @@
7066
"digest"
7167
],
7268
"matchManagers": [
73-
"gomod",
7469
"github-actions",
7570
"maven",
7671
"dockerfile",
@@ -79,11 +74,6 @@
7974
"helm-values",
8075
"docker"
8176
]
82-
},
83-
{
84-
"matchManagers": ["gomod"],
85-
"matchDepTypes": ["indirect"],
86-
"enabled": false
8777
}
8878
]
8979
}

0 commit comments

Comments
 (0)