Fix registry login: secrets are not environment variables
Some checks failed
build / container (push) Failing after 4s
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:
@@ -132,12 +132,23 @@ jobs:
|
||||
# to publish an image into this registry.
|
||||
- name: Log in to the registry
|
||||
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: |
|
||||
set -eu
|
||||
token="${REGISTRY_TOKEN:-${GITHUB_TOKEN:-}}"
|
||||
token="${TOKEN_FROM_SECRET:-}"
|
||||
if [ -z "$token" ]; then
|
||||
echo "::error::no registry token available; set a"
|
||||
echo "REGISTRY_TOKEN secret (scope: write:package)"
|
||||
token="${TOKEN_FROM_GITEA:-}"
|
||||
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
|
||||
fi
|
||||
printf '%s' "$token" |
|
||||
|
||||
Reference in New Issue
Block a user