fix(template): keep the job's Forgejo token away from mise in CI #4

Merged
jonnxor merged 1 commit from jonnxor/fix/template-ci-github-token into main 2026-10-13 23:25:09 +00:00 AGit
Owner

Problem

The Forgejo Actions runner sets GITHUB_TOKEN to the job's Forgejo token. mise uses GITHUB_TOKEN when it asks api.github.com about a tool (ubi, aqua and github backends), so a Forgejo token goes to GitHub and the request fails with 401. Seen on 2026-10-13 in WAAAGH/jonnxor-is PR 3 (run 9, mise 2026.10.8, ubi:lycheeverse/lychee).

Fix

GITHUB_TOKEN: "" on each of the three mise steps (mise install, mise run lint, mise run test), with one comment explaining why.

Why step level and not job level

The request was a job-level GITHUB_TOKEN: "" next to MISE_YES, as jonnxor-is has it. That does not work on this runner:

  • Runner v13.2.0 (the version in the job logs), act/runner/step.go: mergeEnv copies the job env into the step env, then withGithubEnv sets GITHUB_TOKEN to the job token unconditionally. Only the step's own env: is merged after that.
  • No jonnxor-is run shows otherwise. The commit that added the job-level blank (33a98b9) also moved lychee to a plain URL download, so since run 10 nothing in that job calls the GitHub API. Runs 10–13 pass whether or not the variable is blank.

actions/checkout is unaffected either way: it authenticates with its token input, not the env var, and the mise steps come after it.

Tested

  • Rendered with copier copy --trust --defaults --vcs-ref HEAD -d project_name=demo, with and without use_sops; both ci.yml files parse as YAML and carry the blank on the three mise steps.
  • mise 2026.10.8 locally, forced to call the API (MISE_USE_VERSIONS_HOST=0 mise ls-remote github:lycheeverse/lychee): a blank GITHUB_TOKEN succeeds anonymously, a wrong token gets the 401.
  • Not run on the real runner. The step-level precedence comes from reading the runner source, not from a job log.

Follow-up, not in this PR

repos/jonnxor-is/.forgejo/workflows/ci.yml still has the job-level line, which does nothing. It is harmless until a tool there needs the GitHub API again.

🤖 Generated with Claude Code

## Problem The Forgejo Actions runner sets `GITHUB_TOKEN` to the job's Forgejo token. mise uses `GITHUB_TOKEN` when it asks api.github.com about a tool (ubi, aqua and github backends), so a Forgejo token goes to GitHub and the request fails with 401. Seen on 2026-10-13 in WAAAGH/jonnxor-is PR 3 (run 9, mise 2026.10.8, `ubi:lycheeverse/lychee`). ## Fix `GITHUB_TOKEN: ""` on each of the three mise steps (`mise install`, `mise run lint`, `mise run test`), with one comment explaining why. ## Why step level and not job level The request was a job-level `GITHUB_TOKEN: ""` next to `MISE_YES`, as `jonnxor-is` has it. That does not work on this runner: - Runner v13.2.0 (the version in the job logs), `act/runner/step.go`: `mergeEnv` copies the job env into the step env, then `withGithubEnv` sets `GITHUB_TOKEN` to the job token unconditionally. Only the step's own `env:` is merged after that. - No `jonnxor-is` run shows otherwise. The commit that added the job-level blank (33a98b9) also moved lychee to a plain URL download, so since run 10 nothing in that job calls the GitHub API. Runs 10–13 pass whether or not the variable is blank. `actions/checkout` is unaffected either way: it authenticates with its `token` input, not the env var, and the mise steps come after it. ## Tested - Rendered with `copier copy --trust --defaults --vcs-ref HEAD -d project_name=demo`, with and without `use_sops`; both `ci.yml` files parse as YAML and carry the blank on the three mise steps. - mise 2026.10.8 locally, forced to call the API (`MISE_USE_VERSIONS_HOST=0 mise ls-remote github:lycheeverse/lychee`): a blank `GITHUB_TOKEN` succeeds anonymously, a wrong token gets the 401. - **Not run on the real runner.** The step-level precedence comes from reading the runner source, not from a job log. ## Follow-up, not in this PR `repos/jonnxor-is/.forgejo/workflows/ci.yml` still has the job-level line, which does nothing. It is harmless until a tool there needs the GitHub API again. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fix(template): keep the job's Forgejo token away from mise in CI
All checks were successful
CI / sanity (pull_request) Successful in 6s
d073c5cfed
The runner sets GITHUB_TOKEN to the job's Forgejo token. mise sends it to
api.github.com when it resolves a tool (ubi, aqua and github backends) and
GitHub answers 401 — seen in WAAAGH/jonnxor-is PR 3 with mise 2026.10.8 and
ubi:lycheeverse/lychee.

Blank the variable on each mise step. A job-level value has no effect:
the runner (v13.2.0, act/runner/step.go mergeEnv) writes GITHUB_TOKEN over
the job env for every step, and only step-level env is merged after that.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
WAAAGH/_workdesk!4
No description provided.