ci: use Gitea's built-in GITEA_TOKEN for registry push, drop manual PAT
GITEA_PACKAGE_TOKEN was never a creatable secret name (GITEA_ prefix is reserved), and Gitea Actions' built-in token can be granted registry write access directly via `permissions: packages: write` (per https://docs.gitea.com/usage/actions/token-permissions/) - the "unauthorized: reqPackageAccess" issue noted earlier looks to have been exactly this: the default restricted token mode denying package write unless a job explicitly requests it, not an unfixable bug in the token itself. Drops the manual-PAT requirement entirely - no secret to create or maintain.
This commit is contained in:
@@ -13,15 +13,12 @@ name: Provision Coder Templates
|
|||||||
# CODER_URL e.g. https://code.octoturge.com
|
# CODER_URL e.g. https://code.octoturge.com
|
||||||
# CODER_SESSION_TOKEN a token from `coder tokens create`, ideally under a
|
# CODER_SESSION_TOKEN a token from `coder tokens create`, ideally under a
|
||||||
# dedicated service account rather than a personal one
|
# dedicated service account rather than a personal one
|
||||||
# PACKAGE_REGISTRY_TOKEN a Gitea access token (user Settings > Applications)
|
#
|
||||||
# with write:package scope, for pushing each
|
# Pushing each Dockerfile-having template's image to this instance's
|
||||||
# Dockerfile-having template's image to this
|
# container registry uses Gitea's own built-in secrets.GITEA_TOKEN (no
|
||||||
# instance's container registry. Only the octoturge
|
# manually-created PAT needed) - build-images grants it write access via
|
||||||
# account's own token is used - docker login below
|
# `permissions: packages: write` below. See
|
||||||
# hardcodes that username to match. Named without a
|
# https://docs.gitea.com/usage/actions/token-permissions/
|
||||||
# GITEA_ prefix because Gitea Actions reserves that
|
|
||||||
# prefix for its own built-in secrets and rejects
|
|
||||||
# creating one with that name.
|
|
||||||
#
|
#
|
||||||
# Any templates/<env>/ that has its own Dockerfile gets its image built and
|
# Any templates/<env>/ that has its own Dockerfile gets its image built and
|
||||||
# pushed here (build-images, on the dedicated "docker-build" runner - see
|
# pushed here (build-images, on the dedicated "docker-build" runner - see
|
||||||
@@ -52,6 +49,11 @@ jobs:
|
|||||||
# container.volumes mount for the same path here fails at container
|
# container.volumes mount for the same path here fails at container
|
||||||
# creation with "Duplicate mount point: /var/run/docker.sock".
|
# creation with "Duplicate mount point: /var/run/docker.sock".
|
||||||
runs-on: docker-build
|
runs-on: docker-build
|
||||||
|
# The default token permission mode denies package write unless a job
|
||||||
|
# explicitly asks for it - without this, docker push fails with
|
||||||
|
# "unauthorized: reqPackageAccess".
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
outputs:
|
outputs:
|
||||||
failed_templates: ${{ steps.build.outputs.failed_templates }}
|
failed_templates: ${{ steps.build.outputs.failed_templates }}
|
||||||
# docker:27-cli (Alpine) has no bash - only the POSIX /bin/sh (busybox
|
# docker:27-cli (Alpine) has no bash - only the POSIX /bin/sh (busybox
|
||||||
@@ -77,11 +79,7 @@ jobs:
|
|||||||
id: build
|
id: build
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
if [ -z "${{ secrets.PACKAGE_REGISTRY_TOKEN }}" ]; then
|
echo "${{ secrets.GITEA_TOKEN }}" | docker login git.octoturge.com -u "${{ github.actor }}" --password-stdin
|
||||||
echo "::error::PACKAGE_REGISTRY_TOKEN secret is empty or unset (Settings > Actions > Secrets on this repo) - can't log in to the registry."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "${{ secrets.PACKAGE_REGISTRY_TOKEN }}" | docker login git.octoturge.com -u octoturge --password-stdin
|
|
||||||
|
|
||||||
FAILED=""
|
FAILED=""
|
||||||
for dockerfile in templates/*/Dockerfile; do
|
for dockerfile in templates/*/Dockerfile; do
|
||||||
|
|||||||
Reference in New Issue
Block a user