Add manual Docker rebuild dispatcher

Introduce a manual re-dispatch workflow and wire automatic dispatch from releases to the Docker workflow. dispatch-docker-release.yml was converted to a workflow_dispatch-based "Re-dispatch Docker Release" that accepts snowluma_tag, docker_image_override and platforms_override inputs and forwards them (plus source repository) to the downstream docker-image.yml in the Docker release repo. release.yml gains a dispatch-docker job that runs after the release job and uses a PAT to invoke the same downstream workflow for newly published tags. These changes let maintainers rebuild Docker images for existing tags (e.g. to fix Dockerfile issues or rotate credentials) without re-tagging, and ensure the downstream dispatch runs under the configured token.
This commit is contained in:
手瓜一十雪 committed 2026-05-09 11:07:59 +08:00
1 parent 5a5b9d13d1
commit a978d27f3a
2 files changed
+91 -17

No files matched your search

+36 -17
View File
@@ -1,9 +1,27 @@
name: Dispatch Docker Release
name: Re-dispatch Docker Release
# Manual-only re-dispatcher for SnowLuma.Docker.Framework's docker-image.yml.
#
# The normal flow is automatic: release.yml's `dispatch-docker` job fires
# after a tag-triggered release is published. This workflow exists for
# rebuilding an existing release's Docker image without re-tagging — for
# example after fixing the Dockerfile, rotating a Docker Hub credential,
# or backfilling an older tag.
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
snowluma_tag:
description: 'SnowLuma release tag to rebuild (e.g. v0.5.0)'
required: true
docker_image_override:
description: 'Override Docker image name (defaults to vars.DOCKER_IMAGE)'
required: false
default: ''
platforms_override:
description: 'Override platforms (defaults to vars.DOCKER_PLATFORMS or linux/amd64,linux/arm64)'
required: false
default: ''
permissions:
contents: read
@@ -13,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
environment: SnowLuma
steps:
- name: Dispatch Docker release request
- name: Dispatch Docker rebuild
uses: actions/github-script@v8
env:
RELEASE_REPOSITORY: ${{ vars.DOCKER_RELEASE_REPOSITORY }}
@@ -21,6 +39,9 @@ jobs:
DOCKER_PLATFORMS: ${{ vars.DOCKER_PLATFORMS }}
DOCKER_WORKFLOW: ${{ vars.DOCKER_WORKFLOW }}
DOCKER_REF: ${{ vars.DOCKER_REF }}
SNOWLUMA_TAG: ${{ inputs.snowluma_tag }}
IMAGE_OVERRIDE: ${{ inputs.docker_image_override }}
PLATFORMS_OVERRIDE: ${{ inputs.platforms_override }}
with:
github-token: ${{ secrets.DOCKER_RELEASE_TOKEN }}
script: |
@@ -29,20 +50,16 @@ jobs:
throw new Error('Set SnowLuma environment variable DOCKER_RELEASE_REPOSITORY to owner/repo.');
}
const tag = process.env.SNOWLUMA_TAG;
if (!tag) throw new Error('snowluma_tag input is required.');
const [owner, repo] = target.split('/');
const refName = context.ref.replace('refs/tags/', '');
const image = process.env.DOCKER_IMAGE || 'motricseven7/snowluma';
const platforms = process.env.DOCKER_PLATFORMS || 'linux/amd64,linux/arm64';
const sourceRepo = context.repo.owner + '/' + context.repo.repo;
const image = process.env.IMAGE_OVERRIDE || process.env.DOCKER_IMAGE || 'motricseven7/snowluma';
const platforms = process.env.PLATFORMS_OVERRIDE || process.env.DOCKER_PLATFORMS || 'linux/amd64,linux/arm64';
const workflowId = process.env.DOCKER_WORKFLOW || 'docker-image.yml';
const ref = process.env.DOCKER_REF || 'main';
// The target repo (SnowLuma.Docker.Framework) only declares an
// `on: workflow_dispatch` trigger on docker-image.yml — it has no
// `repository_dispatch` listener, so an older
// `repos.createDispatchEvent` call would arrive but match nothing
// and be silently dropped. We invoke `workflow_dispatch` directly
// with inputs matching that workflow's declared schema (image,
// tag, push, platforms).
await github.rest.actions.createWorkflowDispatch({
owner,
repo,
@@ -50,10 +67,12 @@ jobs:
ref,
inputs: {
image,
tag: refName,
tag,
push: 'true',
platforms,
snowluma_tag: tag,
snowluma_repository: sourceRepo,
},
});
core.info(`Dispatched ${workflowId}@${ref} on ${target} with image=${image} tag=${refName} platforms=${platforms}.`);
core.info(`Re-dispatched ${workflowId}@${ref} on ${target} for SnowLuma release ${sourceRepo}@${tag} (image=${image}, platforms=${platforms}).`);
+55
View File
@@ -157,3 +157,58 @@ jobs:
overwrite_files: true
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}
# Triggers the Docker image build on SnowLuma.Docker.Framework once the
# GitHub Release (and its per-arch tarballs) is published, so the Docker
# workflow can pull the matching `SnowLuma-<tag>-linux-<arch>-lite.tar.gz`
# asset and bake it into the container.
#
# Chained as a job dependency rather than via `on: release: published`
# because workflows triggered by GITHUB_TOKEN cannot fire downstream
# workflow events (GitHub anti-loop safeguard). Doing it as `needs: release`
# keeps the dispatch under our PAT.
dispatch-docker:
needs: release
runs-on: ubuntu-latest
environment: SnowLuma
steps:
- name: Trigger Docker.Framework workflow_dispatch
uses: actions/github-script@v8
env:
RELEASE_REPOSITORY: ${{ vars.DOCKER_RELEASE_REPOSITORY }}
DOCKER_IMAGE: ${{ vars.DOCKER_IMAGE }}
DOCKER_PLATFORMS: ${{ vars.DOCKER_PLATFORMS }}
DOCKER_WORKFLOW: ${{ vars.DOCKER_WORKFLOW }}
DOCKER_REF: ${{ vars.DOCKER_REF }}
with:
github-token: ${{ secrets.DOCKER_RELEASE_TOKEN }}
script: |
const target = process.env.RELEASE_REPOSITORY;
if (!target || !target.includes('/')) {
throw new Error('Set SnowLuma environment variable DOCKER_RELEASE_REPOSITORY to owner/repo.');
}
const [owner, repo] = target.split('/');
const tag = context.ref.replace('refs/tags/', '');
const sourceRepo = context.repo.owner + '/' + context.repo.repo;
const image = process.env.DOCKER_IMAGE || 'motricseven7/snowluma';
const platforms = process.env.DOCKER_PLATFORMS || 'linux/amd64,linux/arm64';
const workflowId = process.env.DOCKER_WORKFLOW || 'docker-image.yml';
const ref = process.env.DOCKER_REF || 'main';
await github.rest.actions.createWorkflowDispatch({
owner,
repo,
workflow_id: workflowId,
ref,
inputs: {
image,
tag,
push: 'true',
platforms,
snowluma_tag: tag,
snowluma_repository: sourceRepo,
},
});
core.info(`Dispatched ${workflowId}@${ref} on ${target} for SnowLuma release ${sourceRepo}@${tag} (image=${image}, platforms=${platforms}).`);