action: version resolution and binary download fail when running on GitHub #120
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The composite action in
.gitea/actions/review/action.ymlhardcodes Gitea assumptions that break when running on GitHub Enterprise Server:REPOis hardcoded torodin/review-bot— should be the repo hosting the action on the current server/api/v1/repos/...) — GitHub uses/api/v3/repos/...(or REST/repos/...)https://gitea.weiker.me/rodin/review-bot/releases/download/...vs GitHub:https://github.concur.com/strat/review-bot/releases/download/...Observed
When running on
github.concur.comrunners:The version resolution curl hits
https://github.concur.com/api/v1/repos/rodin/review-bot/releases— wrong API format and wrong repo.Fix
The action should:
github.server_urlrodin/review-botaction-repoinput that defaults to the Gitea value for backward compatibilityContext
Discovered while testing GitHub support (feature/github-support) against
strat/db-migratorongithub.concur.com.Plan: Fix version resolution and binary download for GitHub hosts
Problem
The composite action in both
.gitea/actions/review/action.ymland.github/actions/review/action.ymlhas three Gitea-specific assumptions that break on GitHub/GHES:REPOdefaults torodin/review-bot— on GHES the action lives in a different repo (e.g.strat/review-bot)/api/v1/repos/{owner}/{repo}/releasesbut GitHub uses/repos/{owner}/{repo}/releases(REST v3){server}/{repo}/releases/download/{tag}/{asset}, GitHub:{server}/{repo}/releases/download/{tag}/{asset}(same pattern but the API endpoint differs)Constraints
repoinput should work unchanged.giteaand.githubaction files must be updatedinputs.gitea-urlname stays for backward compat (renaming would break callers)Proposed Approach
Host detection: Determine whether we're on Gitea or GitHub by checking the releases API. A simple heuristic: if
github.server_urlcontainsgithub.comor the/api/v3/endpoint responds, treat it as GitHub. Otherwise assume Gitea.Actually, a cleaner approach: use the API format that matches the host. The action can try the Gitea endpoint first, and if it fails (non-JSON response), fall back to GitHub REST API. But that's fragile.
Simplest reliable approach:
action-repothat specifies where to find review-bot releases. Defaults torodin/review-botfor backward compat.github.server_url:github.comOR returns a GitHub-style API response → GitHub mode${SERVER_URL}/api/v1/repos/${REPO}/releases?limit=1${SERVER_URL}/api/v3/repos/${REPO}/releases?per_page=1(GHES uses/api/v3/)${SERVER_URL}/${REPO}/releases/download/${VERSION}/${BINARY}Wait — checking the actual GitHub releases download URL format... On GHES it's:
https://github.concur.com/{owner}/{repo}/releases/download/{tag}/{asset}which IS the same pattern as Gitea. So the download URL logic is fine as-is. The only real issue is the releases API path and the repo default.Revised approach (minimal change):
action-repoinput that defaults to empty (meaning: usegithub.repositorycontext)inputs.action-repo || inputs.repo || github.repository— but wait,inputs.repois the target repo being reviewed, not the repo hosting the action. We need to separate these.Actually re-reading the code more carefully:
inputs.repoin "Run review" = the repo being reviewed (target)REPOin "Determine version" and "Install review-bot" = the repo hosting review-bot releases (action source)These are different repos and currently both default to
rodin/review-botwhich conflates them.Final approach:
action-repoinput (default: empty) — the repo that hosts review-bot releasesaction-repois empty, derive it fromgithub.action_repository(GitHub Actions provides this as the repo containing the action being run) — but Gitea Actions may not support this. Fallback: hardcoderodin/review-botif empty (maintains backward compat for Gitea).${SERVER_URL}/api/v3/path exists (GitHub/GHES)/api/v1/(Gitea)/api/v1/if it returns valid JSON, else try/api/v3/Simplest implementation (avoiding API probing):
vcs-typewith valuesauto|gitea|github, defaulting toautoautodetection: ifgithub.server_urlmatches*github*→ github, else → giteagithub.com,github.concur.com,github.yourcompany.ioetc.Implementation Details
New inputs:
"Determine version" step changes:
"Install review-bot" step changes:
Same pattern — use
ACTION_REPOand the server URL directly for download (download URL format is the same on both platforms)."Run review" step:
Already uses
inputs.repo || github.repositoryfor the target repo. The env var names differ between.gitea(GITEA_URL/GITEA_REPO) and.github(GITHUB_SERVER_URL/GITHUB_REPOSITORY) — that's fine and intentional.Testing Strategy
gitea.weiker.meaction-repoinput explicitly with a GHES-style URLgitea-urltohttps://github.concur.comandaction-repotostrat/review-botEdge Cases
github.action_repositorymight not be available in Gitea Actions → fallback torodin/review-botvcs-typeoraction-repoinput covers thisOpen Questions
github.action_repository: Gitea Actions might support this (it emulates GitHub Actions context). Need to verify. If it does, noaction-repoinput needed at all — just usegithub.action_repositorywithrodin/review-botfallback.release-tokeninput later if needed).Completion Checklist
.giteaand.githubaction files updated with host detectionaction-repoinput added with sensible defaultsinputs.repo(target repo for review) kept separate from action repo