How the action works
This action is designed to propagate a Go version change across a repository after the source Docker image has already been updated.
Intended flow
The usual workflow is:
- Update a Dockerfile in the target repository so it uses a newer Go image, typically from the official
golangDocker image. - Run
update-go-actionand point it at that Dockerfile. - The action reads the Go version from the Dockerfile.
- The action updates other files that mention the Go version, based on
rules.json. - If configured by a rule, the action runs
go mod tidyorgo work syncso Go module files stay consistent.
The action does not update the Dockerfile itself. It assumes the Dockerfile version change already happened and then synchronises the rest of the repository to match it.
Version source
The action extracts the version from the Docker image reference in the configured Dockerfile.
Today it matches image references like:
golang:1.23.4golang:v1.23.4ghcr.io/goreleaser/goreleaser-cross:v1.23.4
It derives two values from that image tag:
GO_FULL_VERSION: the full version, such as1.23.4GO_SHORT_VERSION: the major and minor version, such as1.23
How replacements happen
Replacement logic is defined in rules.json.
Each rule tells the action:
- which directory to search
- which filenames to match
- which pattern to replace
- which replacement string to use
- whether to recurse into subdirectories
- whether the matching file should trigger
go mod tidyorgo work sync
Rules can use these placeholders inside replacement text:
GO_FULL_VERSIONGO_SHORT_VERSION
This allows the action to update different file types correctly. For example:
go.modandgo.workusually use the short version, such asgo 1.23- CI configuration often uses the full version, such as
1.23.4 - README badges or snippets may also use the full version
Post-processing
When a rule has go_mod_tidy: true:
- matched
go.moddirectories are collected andgo mod tidyis run once per directory - matched
go.workdirectories are collected andgo work syncis run once per directory
This happens after all text replacements have completed.
Commit behaviour
If any files changed and no-commit is not true, the action commits the updated files automatically.
If no-commit: true is set, the action still performs the updates but leaves the changes uncommitted.
The action operates on the branch checked out by actions/checkout. Select a target branch with its ref input. The action's branch input is deprecated and ignored, but remains accepted for v1 compatibility.
Private dependencies
If go mod tidy or go work sync needs access to private Go modules, provide:
tokenprivate-module-prefix
When both inputs are set, the action:
- sets
GOPRIVATE - rewrites HTTPS clone URLs for that prefix to include the token
If either input is missing, private dependency setup is skipped.
private-module-prefix defaults to github.com/Arm-Debug, so providing only token uses that prefix automatically.
For GitHub-hosted repositories, the rewritten URL uses the x-access-token HTTPS form documented by GitHub:
https://x-access-token:<token>@github.com/owner-or-org
References: