fix(ci): derive the image name from GITHUB_REPOSITORY - #1708
Merged
Conversation
The Github CI provider took the image name from the last path element of RUNNER_WORKSPACE. That holds on GitHub Actions, which checks out to /home/runner/work/<repository>, but not on Gitea Actions: it checks out to /workspace/<owner>/<repository> and exports the parent of that as RUNNER_WORKSPACE, so the last element is the owner. Images were therefore published as <owner>/<owner> instead of <owner>/<repository>, and deployments referencing the expected name failed to pull. The breakage only surfaced once the runner started exporting RUNNER_WORKSPACE at all; before that the empty value fell through to the working directory basename, which happened to be correct. GITHUB_REPOSITORY is "<owner>/<repository>" on both platforms and names the repository directly, so prefer it and keep the old paths as fallbacks.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1708 +/- ##
=======================================
Coverage 90.89% 90.90%
=======================================
Files 40 40
Lines 1923 1924 +1
=======================================
+ Hits 1748 1749 +1
Misses 113 113
Partials 62 62
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ 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.
The Github CI provider derived the image name from the last path element of
RUNNER_WORKSPACE:That holds on GitHub Actions, which checks out to
/home/runner/work/<repository>. It does not hold on Gitea Actions, which checks out to/workspace/<owner>/<repository>and exports the parent of the workspace, so the last element is the owner:RUNNER_WORKSPACEfilepath.Base/home/runner/work/myrepomyrepo✅/workspace/myorgmyorg❌Images were published as
<registry>/<owner>/<owner>instead of<registry>/<owner>/<repository>— for us,oci.example.com/myorg/myorg— and every deployment referencing the expected name failed to pull with a 404.This stayed hidden for as long as the Gitea runner left
RUNNER_WORKSPACEunset, because the empty value fell through toCommon.BuildName("")→filepath.Base(cwd), and the working directory basename is the repository name. Once the runner started exporting the variable, the name changed under us with no change on our side.GITHUB_REPOSITORYis<owner>/<repository>on both platforms and names the repository directly, so this prefers it and keeps the previous paths as fallbacks. On GitHub Actions the result is identical to before.Tests
Two new cases in
pkg/ci/github_test.go: one for a GitHub-shaped workspace (asserting no behaviour change) and one for the Gitea layout, whereRUNNER_WORKSPACEpoints at the owner andGITHUB_REPOSITORYhas to win. Reverting the fix turns the Gitea case red and leaves the GitHub one green.TestGithub_Override_ImageNamestill passes, so an explicitIMAGE_NAMEcontinues to beat both.