Skip to content

Commit ac9382a

Browse files
authored
Merge pull request #938 from jingxu97/patch-1
Update update-deps.yml with dockerfile update
2 parents c123ddd + 09c3cfe commit ac9382a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

.github/workflows/update-deps.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,38 @@ jobs:
4343
labels: ok-to-test
4444
body: |
4545
Updating go.mod with latest dependencies...
46+
update-go-version:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v3
51+
52+
- name: Get current Go version from Dockerfile
53+
id: current-go-version
54+
run: |
55+
# Read the Dockerfile content
56+
DOCKERFILE_CONTENT=$(cat Dockerfile)
57+
58+
# Extract the current Go version using regex
59+
CURRENT_GO_VERSION=$(echo "$DOCKERFILE_CONTENT" | grep -oP 'FROM golang:\K\d+\.\d+(\.\d+)?')
60+
echo "current_go_version=${CURRENT_GO_VERSION}" >> $GITHUB_OUTPUT
61+
62+
- name: Get latest Go version
63+
id: go-version
64+
run: |
65+
# Fetch the Go download page and extract the latest version
66+
LATEST_GO_VERSION=$(curl -s https://go.dev/dl/ | grep -oP 'go1\.22\.\d+' | sort -rV | head -n 1)
67+
echo "latest_go_version=${LATEST_GO_VERSION}" >> $GITHUB_OUTPUT
68+
69+
- name: Update Go version
70+
uses: jacobtomlinson/gha-find-replace@v2
71+
with:
72+
find: "FROM golang:${{ steps.current-go-version.outputs.current_go_version }}-bookworm as builder-base"
73+
replace: "FROM golang:${{ steps.go-version.outputs.latest_go_version }}-bookworm as builder-base"
74+
path: "Dockerfile"
75+
76+
- name: Commit and push changes (optional)
77+
uses: stefanzweifel/git-auto-commit-action@v4
78+
with:
79+
commit_message: "Update Go version in Dockerfile"
80+

0 commit comments

Comments
 (0)