File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 43
43
labels : ok-to-test
44
44
body : |
45
45
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
+
You can’t perform that action at this time.
0 commit comments