Skip to content

chore: auto-open a PR when the pinned Go toolchain goes stale - #511

Open
tylerpotts wants to merge 3 commits into
mainfrom
chore/auto-bump-go-toolchain
Open

chore: auto-open a PR when the pinned Go toolchain goes stale#511
tylerpotts wants to merge 3 commits into
mainfrom
chore/auto-bump-go-toolchain

Conversation

@tylerpotts

Copy link
Copy Markdown
Collaborator

Summary

Stops the problem behind #510 from needing a human every time. Every Go patch release closes standard library vulnerabilities, so the day one ships, the govulncheck gates and the Trivy image scan begin failing on main and on every open PR at once. That is exactly how go1.26.5 surfaced: as an unrelated frontend PR going red, not as a toolchain signal. check-go-toolchain.sh only warns on a stale patch outside the release gate, so nothing opened the bump.

This adds a daily job that turns that into a two-line PR waiting for review.

Changes

  • scripts/bump-go-toolchain.sh rewrites both places the toolchain is pinned: the toolchain directive in go.mod and the golang builder image tag + digest in the Dockerfile. Follows the existing check-go-toolchain.sh idiom (bash + curl + python3, no new dependencies) and is runnable locally.
  • .github/workflows/go-toolchain-bump.yml runs it daily plus on workflow_dispatch, and opens the PR.

Design decisions worth reviewing

The digest is verified, not trusted. After resolving the multi-arch index digest, the script pulls the image config and confirms it reports the expected GOLANG_VERSION before pinning. Trusting the tag alone would let a mismatched or mid-push image get pinned by digest, which is the one failure mode a digest pin exists to prevent. This is the same check I ran by hand for #510.

Patch bumps only. A major-line move also decides the language version and the go directive, so an unsupported line exits 2 and fails the run loudly instead of opening a PR.

Idempotent via a version-keyed branch (chore/go-toolchain-<version>), so a run that finds the previous bump PR still open leaves it alone.

One caveat that needs a decision

A PR opened with the default GITHUB_TOKEN does not trigger other workflows, so the bump PR would sit with no checks. The workflow uses secrets.BOT_TOKEN || secrets.GITHUB_TOKEN, so:

  • Set a BOT_TOKEN secret (PAT or GitHub App token) and bump PRs get full CI.
  • Without it, the PR still opens correctly but needs a close/reopen to run checks. The generated PR body says so explicitly.

Creating PRs with GITHUB_TOKEN also requires Settings -> Actions -> Allow GitHub Actions to create and approve pull requests to be enabled.

Test plan

Verified locally before pushing:

  • Reproduces the real fix byte-for-byte. Reset go.mod and Dockerfile to the pre-fix go1.26.5 state and ran the script: the resulting diff against security: bump Go toolchain to 1.26.6 #510's known-good commit is empty.
  • Already-current path: exits 0, changed=false, no writes.
  • Unsupported line (go1.20.0): exits 2 with the manual-upgrade error.
  • Missing toolchain directive: exits 1.
  • Workflow YAML parses; the PR step's shell passes bash -n.
  • Dry-ran the PR step with git/gh stubbed: commit message and PR body render correctly (variables expanded, backticks literal, no stray indentation) and the git/gh invocations are right.
  • Idempotency path: with the branch already present upstream, the step short-circuits without pushing.

Note that CI here exercises the repo's normal gates, not this workflow, which only runs on its schedule. The verification above is where the behavior was checked.

Go patch releases carry standard library security fixes, so the day one
ships, the govulncheck gates and the Trivy image scan start failing on
main and on every open PR at once. That is how go1.26.5 surfaced: as an
unrelated frontend PR going red, not as a toolchain signal.
check-go-toolchain.sh only warns on a stale patch outside the release
gate, so nothing opened the bump.

Adds scripts/bump-go-toolchain.sh, which rewrites both pins (the go.mod
toolchain directive and the golang builder image tag + digest in the
Dockerfile), and a daily workflow that runs it and opens a PR.

The script resolves the builder digest from the registry and verifies
the image config reports the expected GOLANG_VERSION before pinning it,
so a mismatched or mid-push tag cannot be pinned by digest.

Patch bumps only. An unsupported release line exits 2 and fails the run
rather than opening a PR, since a major-line move also decides the
language version and the go directive.

The branch name is version-keyed, so a run that finds the previous bump
PR still open leaves it alone.
@netlify

netlify Bot commented Aug 17, 2026

Copy link
Copy Markdown

Deploy Preview for nebi-docs canceled.

Name Link
🔨 Latest commit 8d51c4c
🔍 Latest deploy log https://app.netlify.com/projects/nebi-docs/deploys/6a84d5721ad11300088e19e0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant