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