diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index e78778c..eff8203 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -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" |