Repository navigation
ci: authenticate go-git tag push in publish workflow - #75
Merged
Merged
Conversation
changeset publish pushes tags via go-git, which ignores the http.extraheader credentials actions/checkout configures. The push therefore went out anonymously and failed with "authentication required: No anonymous write access", so no tags were published (xkafka/v0.11.1 had to be tagged manually). Embed the GITHUB_TOKEN in the origin URL (which go-git does read) and grant the job contents: write so the token can push tags.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #75 +/- ##
==========================================
- Coverage 60.37% 60.32% -0.06%
==========================================
Files 80 80
Lines 3599 3599
==========================================
- Hits 2173 2171 -2
- Misses 1396 1398 +2
Partials 30 30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
Publishworkflow failed on the last release (run):All tags were created but none were pushed —
xkafka/v0.11.1(and the cascade dependency tags) had to be pushed manually to complete the release.Root cause
changeset publishpushes via go-git —PushTagscallsrepo.Push(&git.PushOptions{...})with noAuth. go-git does not read thehttp.<url>.extraheadercredential thatactions/checkoutinjects for theGITHUB_TOKEN, so the push goes out anonymously and GitHub rejects it.Fix (workflow-only)
permissions: contents: writeon the job so the token has push scope.originremote URL to embed the token (https://x-access-token:${GITHUB_TOKEN}@github.com/...). go-git does read URL userinfo, so the push now authenticates.No change to the
changesettool or its released version.Follow-up (optional, deeper fix)
The tool itself should authenticate its own push so it works in any CI without URL hacks: add
Auth: &http.BasicAuth{Username: "x-access-token", Password: os.Getenv("GITHUB_TOKEN")}toPushTagsincmd/changeset/git/git.go. Left out here to keep this change to the workflow and avoid re-releasingcmd/changeset.Notes