Fix registry login: secrets are not environment variables
Some checks failed
build / container (push) Failing after 4s

The first pipeline run failed at the login step with "no registry token
available".  `secrets.*` values only exist when named with an expression, so
`${GITHUB_TOKEN}` in the shell was always empty; both candidate tokens are now
mapped into the step's environment and the shell chooses between them.

The rest of the run was healthy: docker was available to the job and the test
stage passed inside it (Ran 276 tests ... OK).
This commit is contained in:
2026-11-15 18:21:51 -05:00
parent 577b29db39
commit 51f5c80d87

View File

@@ -132,12 +132,23 @@ jobs:
# to publish an image into this registry. # to publish an image into this registry.
- name: Log in to the registry - name: Log in to the registry
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
# Secrets are not environment variables -- they only exist when named
# with an expression, which is what this block is for. The fallback
# lives in the shell rather than in a `||` expression so that it does
# not depend on the evaluator supporting either.
env:
TOKEN_FROM_SECRET: ${{ secrets.REGISTRY_TOKEN }}
TOKEN_FROM_GITEA: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
set -eu set -eu
token="${REGISTRY_TOKEN:-${GITHUB_TOKEN:-}}" token="${TOKEN_FROM_SECRET:-}"
if [ -z "$token" ]; then if [ -z "$token" ]; then
echo "::error::no registry token available; set a" token="${TOKEN_FROM_GITEA:-}"
echo "REGISTRY_TOKEN secret (scope: write:package)" fi
if [ -z "$token" ]; then
echo "::error::no registry token available. Gitea's automatic"
echo "token is normally enough; if a push is refused, create a"
echo "PAT with the write:package scope as REGISTRY_TOKEN."
exit 1 exit 1
fi fi
printf '%s' "$token" | printf '%s' "$token" |