mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
Allow manually publishing a release image in docker workflow (#7392)
Add a workflow_dispatch trigger that builds an existing release tag with the current workflow and publishes it to GHCR under that tag name (optionally also as latest). This allows republishing a release whose image failed to publish, since re-running the original run reuses the workflow file from the release tag. Dispatched runs check out the given tag, publish like stable releases, and use their own concurrency group so pushes to master can't cancel them. Co-authored-by: Michael Hogg <3495076+jedinerd@users.noreply.github.com>
This commit is contained in:
parent
76bcc4842b
commit
885b50de00
1 changed files with 22 additions and 7 deletions
29
.github/workflows/docker-release.yml
vendored
29
.github/workflows/docker-release.yml
vendored
|
|
@ -20,11 +20,22 @@ on:
|
||||||
release:
|
release:
|
||||||
types:
|
types:
|
||||||
- released # publishing of stable releases
|
- released # publishing of stable releases
|
||||||
|
workflow_dispatch: # (re)publish the image for an existing stable release
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Existing release tag to build and publish (e.g. 2026-10-03-Release-3.1.0)'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
latest:
|
||||||
|
description: 'Also update the "latest" tag'
|
||||||
|
required: true
|
||||||
|
type: boolean
|
||||||
|
default: true
|
||||||
|
|
||||||
# Cancel earlier, unfinished runs of this workflow on the same branch (unless on release)
|
# Cancel earlier, unfinished runs of this workflow on the same branch (unless publishing)
|
||||||
concurrency:
|
concurrency:
|
||||||
group: "${{ github.workflow }} @ ${{ github.ref_name }}"
|
group: "${{ github.workflow }} @ ${{ inputs.tag || github.ref_name }}"
|
||||||
cancel-in-progress: ${{ github.event_name != 'release' }}
|
cancel-in-progress: ${{ github.event_name != 'release' && github.event_name != 'workflow_dispatch' }}
|
||||||
|
|
||||||
env:
|
env:
|
||||||
GHCR_IMAGE: ghcr.io/cockatrice/servatrice
|
GHCR_IMAGE: ghcr.io/cockatrice/servatrice
|
||||||
|
|
@ -57,12 +68,14 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: "Checkout"
|
- name: "Checkout"
|
||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
ref: ${{ case(github.event_name == 'workflow_dispatch', format('refs/tags/{0}', inputs.tag), '') }}
|
||||||
|
|
||||||
- name: "Set up Docker buildx"
|
- name: "Set up Docker buildx"
|
||||||
uses: docker/setup-buildx-action@v4
|
uses: docker/setup-buildx-action@v4
|
||||||
|
|
||||||
- name: "Login to GitHub Container Registry (GHCR)"
|
- name: "Login to GitHub Container Registry (GHCR)"
|
||||||
if: github.event_name == 'release' && github.event.release.prerelease == false
|
if: (github.event_name == 'release' && github.event.release.prerelease == false) || github.event_name == 'workflow_dispatch'
|
||||||
id: login
|
id: login
|
||||||
uses: docker/login-action@v4
|
uses: docker/login-action@v4
|
||||||
with:
|
with:
|
||||||
|
|
@ -70,7 +83,7 @@ jobs:
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ github.token }}
|
password: ${{ github.token }}
|
||||||
|
|
||||||
# Don't push for non-release triggers
|
# Don't push for non-publishing triggers
|
||||||
- name: "Build image"
|
- name: "Build image"
|
||||||
if: steps.login.outcome != 'success'
|
if: steps.login.outcome != 'success'
|
||||||
uses: docker/build-push-action@v7
|
uses: docker/build-push-action@v7
|
||||||
|
|
@ -120,7 +133,7 @@ jobs:
|
||||||
# Create an OCI image index from the platform-specific image manifests
|
# Create an OCI image index from the platform-specific image manifests
|
||||||
index:
|
index:
|
||||||
name: "Publish multi-platform Servatrice image"
|
name: "Publish multi-platform Servatrice image"
|
||||||
if: github.repository_owner == 'Cockatrice' && github.event_name == 'release' && github.event.release.prerelease == false
|
if: github.repository_owner == 'Cockatrice' && ((github.event_name == 'release' && github.event.release.prerelease == false) || github.event_name == 'workflow_dispatch')
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: ubuntu-slim # https://github.com/actions/runner-images/blob/main/images/ubuntu-slim/ubuntu-slim-Readme.md
|
runs-on: ubuntu-slim # https://github.com/actions/runner-images/blob/main/images/ubuntu-slim/ubuntu-slim-Readme.md
|
||||||
|
|
||||||
|
|
@ -149,6 +162,8 @@ jobs:
|
||||||
# if semver, also: type=semver,pattern={{version}} / {{major}}.{{minor}}
|
# if semver, also: type=semver,pattern={{version}} / {{major}}.{{minor}}
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=tag
|
type=ref,event=tag
|
||||||
|
type=raw,value=${{ inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' }}
|
||||||
|
type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' && inputs.latest }}
|
||||||
|
|
||||||
# Add OCI annotations to image index and publish tags
|
# Add OCI annotations to image index and publish tags
|
||||||
- name: "Create image index"
|
- name: "Create image index"
|
||||||
|
|
@ -176,7 +191,7 @@ jobs:
|
||||||
|
|
||||||
- name: "Inspect images"
|
- name: "Inspect images"
|
||||||
env:
|
env:
|
||||||
GITHUB_TAG: ${{ github.ref_name }}
|
GITHUB_TAG: ${{ inputs.tag || github.ref_name }}
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect "$GHCR_IMAGE:latest"
|
docker buildx imagetools inspect "$GHCR_IMAGE:latest"
|
||||||
docker buildx imagetools inspect "$GHCR_IMAGE:$GITHUB_TAG"
|
docker buildx imagetools inspect "$GHCR_IMAGE:$GITHUB_TAG"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue