Skip to content

Commit 7d5e157

Browse files
chore(deps): bump golang from 1.26.2-alpine3.22 to 1.26.3-alpine3.22 (#254)
1 parent 5097a97 commit 7d5e157

3 files changed

Lines changed: 70 additions & 2 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
name: Sync go.mod with Dockerfile
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- Dockerfile
8+
9+
permissions: {}
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
13+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
14+
15+
jobs:
16+
sync:
17+
name: Sync go.mod
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write # Push the go.mod sync commit back to dependabot branches when they diverge
21+
steps:
22+
- uses: step-security/harden-runner@fe104658747b27e96e4f7e80cd0a94068e53901d # v2.16.1
23+
with:
24+
egress-policy: audit
25+
26+
# Check out the PR head branch (not the merge ref) so any sync commit lands on it.
27+
# persist-credentials is required so the subsequent git push uses GITHUB_TOKEN.
28+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
29+
with:
30+
ref: ${{ github.head_ref }}
31+
persist-credentials: true
32+
33+
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
34+
with:
35+
go-version-file: go.mod
36+
37+
- name: Verify or sync go directive against Dockerfile
38+
env:
39+
IS_DEPENDABOT: ${{ github.actor == 'dependabot[bot]' && startsWith(github.head_ref, 'dependabot/docker/golang') }}
40+
run: |
41+
set -euo pipefail
42+
43+
DOCKERFILE_GO=$(grep -oE 'golang:[0-9]+\.[0-9]+\.[0-9]+' Dockerfile | head -1 | cut -d: -f2)
44+
if [ -z "$DOCKERFILE_GO" ]; then
45+
echo "::error::Could not extract Go version from Dockerfile"
46+
exit 1
47+
fi
48+
49+
GOMOD_GO=$(go mod edit -json | jq -r '.Go')
50+
51+
if [ "$DOCKERFILE_GO" = "$GOMOD_GO" ]; then
52+
echo "go.mod and Dockerfile both at Go $GOMOD_GO"
53+
exit 0
54+
fi
55+
56+
if [ "$IS_DEPENDABOT" != "true" ]; then
57+
echo "::error file=go.mod::Dockerfile is on Go $DOCKERFILE_GO but go.mod is on $GOMOD_GO. Run: go mod edit -go=$DOCKERFILE_GO"
58+
exit 1
59+
fi
60+
61+
echo "Bumping go.mod from $GOMOD_GO to $DOCKERFILE_GO"
62+
go mod edit -go="$DOCKERFILE_GO"
63+
64+
git config user.name 'github-actions[bot]'
65+
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
66+
git add go.mod
67+
git commit -m "chore(deps): sync go.mod to Go $DOCKERFILE_GO"
68+
git push

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.26.2-alpine3.22@sha256:7ef941168f213aa115df2e61364d67682129e99dc8188b734139dea862cc7d31 AS build
1+
FROM golang:1.26.3-alpine3.22@sha256:be93003ee861b3b91b6ebcb22678524947e0cd786c2df3f32af520006b1e54f5 AS build
22

33
WORKDIR /app
44

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/privateerproj/privateer
22

3-
go 1.26.2
3+
go 1.26.3
44

55
require (
66
github.com/hashicorp/go-hclog v1.6.3

0 commit comments

Comments
 (0)