Fix container publish workflow to target the right registry per runner
Publish container / publish (push) Failing after 22s
Publish container / publish (push) Failing after 22s
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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user