Files
vboxstock/.github/workflows/publish-container.yml
T
mfwadejr 05d24933f1
Publish container / publish (push) Failing after 22s
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.
2026-09-21 22:28:30 +00:00

56 lines
1.5 KiB
YAML

name: Publish container
on:
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out source
uses: actions/checkout@v6
- 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: ${{ steps.registry.outputs.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate image tags
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.registry.outputs.image }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=sha
- name: Build and publish image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}