diff --git a/.github/workflows/publish-image.yml b/.github/workflows/publish-image.yml index 4a74dca..95f648e 100644 --- a/.github/workflows/publish-image.yml +++ b/.github/workflows/publish-image.yml @@ -41,7 +41,9 @@ jobs: arch: arm64 env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + # Per-arch images always go to -edge, with this repository's own token; + # the release package receives them only through the manifest job below. + IMAGE_NAME: ${{ github.repository }}-edge steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -128,6 +130,7 @@ jobs: name: Create multi-arch manifest and sign needs: build if: github.event_name != 'pull_request' + environment: ${{ startsWith(github.ref, 'refs/tags/v') && 'release' || 'edge' }} runs-on: ubuntu-latest permissions: contents: read @@ -136,7 +139,8 @@ jobs: timeout-minutes: 20 env: REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + IMAGE_NAME: ${{ startsWith(github.ref, 'refs/tags/v') && github.repository || format('{0}-edge', github.repository) }} + EDGE_IMAGE_NAME: ${{ github.repository }}-edge steps: - name: Set up Docker Buildx (for imagetools) uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 @@ -145,8 +149,12 @@ jobs: uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 with: registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} + # GHCR_PUBLISH_TOKEN (classic PAT, write:packages, machine user) exists only in + # the `release` environment. Once the release package's Actions access is locked + # to read, this repository's GITHUB_TOKEN cannot push to it; until then the + # fallback keeps releases working. + username: ${{ secrets.GHCR_PUBLISH_TOKEN && vars.GHCR_PUBLISH_USER || github.actor }} + password: ${{ secrets.GHCR_PUBLISH_TOKEN || secrets.GITHUB_TOKEN }} - name: Compute canonical image name (lowercase) id: vars @@ -192,6 +200,8 @@ jobs: ref="${GITHUB_REF#refs/tags/}" src_tag="${tag%:latest}:$ref" fi + # The per-arch sources always live in the edge package. + src_tag="${REGISTRY}/${EDGE_IMAGE_NAME,,}:${src_tag##*:}" if [ -n "${IMAGE_DESCRIPTION:-}" ]; then docker buildx imagetools create \ --tag "$tag" \