From 05d24933f17a62b372a47d218655f0dfda4cc3c2 Mon Sep 17 00:00:00 2001 From: mfwadejr <125498560+mfwadejr@users.noreply.github.com> Date: Mon, 21 Sep 2026 22:28:30 +0000 Subject: [PATCH] Fix container publish workflow to target the right registry per runner The compose files were switched to pull from the Gitea registry (git.us2plus2.com/marvin/vboxstock), but publish-container.yml was left hardcoded to ghcr.io. Gitea Actions also executes .github/workflows, so every push ran this job twice: it succeeded on GitHub (real GITHUB_TOKEN, publishing to ghcr.io, which nothing consumes) and failed on Gitea every time (Gitea's own GITHUB_TOKEN isn't valid for github.com's registry). Now the registry/image target is derived from github.server_url, so each runner logs into and publishes to its own registry with its own automatic token. --- .github/workflows/publish-container.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-container.yml b/.github/workflows/publish-container.yml index 4a18785..a95ac92 100644 --- a/.github/workflows/publish-container.yml +++ b/.github/workflows/publish-container.yml @@ -6,10 +6,6 @@ on: tags: ["v*"] workflow_dispatch: -env: - REGISTRY: ghcr.io - IMAGE_NAME: mfwadejr/vboxstock - jobs: publish: runs-on: ubuntu-latest @@ -21,10 +17,22 @@ jobs: - name: Check out source uses: actions/checkout@v6 - - name: Sign in to GitHub Container Registry + - name: Determine target registry + id: registry + run: | + if [ "${{ github.server_url }}" = "https://github.com" ]; then + echo "registry=ghcr.io" >> "$GITHUB_OUTPUT" + echo "image=ghcr.io/mfwadejr/vboxstock" >> "$GITHUB_OUTPUT" + else + host="$(printf '%s' '${{ github.server_url }}' | sed -E 's#^https?://##')" + echo "registry=$host" >> "$GITHUB_OUTPUT" + echo "image=$host/marvin/vboxstock" >> "$GITHUB_OUTPUT" + fi + + - name: Sign in to container registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ${{ steps.registry.outputs.registry }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -32,7 +40,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ steps.registry.outputs.image }} tags: | type=raw,value=latest,enable={{is_default_branch}} type=ref,event=tag