Files
SnowLuma/.github/workflows/dispatch-docker-release.yml
T
手瓜一十雪 5a5b9d13d1 Use workflow_dispatch to trigger Docker workflow
Switch the release dispatch to call actions.createWorkflowDispatch instead of repos.createDispatchEvent because the target repo only listens for workflow_dispatch on its docker workflow. Add env vars DOCKER_PLATFORMS, DOCKER_WORKFLOW and DOCKER_REF (with sensible defaults) and pass image, tag, push and platforms as inputs. Update log output to include workflow, ref, image, tag and platforms.
2026-05-09 10:47:29 +08:00

60 lines
2.2 KiB
YAML

name: Dispatch Docker Release
on:
push:
tags:
- 'v*'
permissions:
contents: read
jobs:
dispatch:
runs-on: ubuntu-latest
environment: SnowLuma
steps:
- name: Dispatch Docker release request
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 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 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,
workflow_id: workflowId,
ref,
inputs: {
image,
tag: refName,
push: 'true',
platforms,
},
});
core.info(`Dispatched ${workflowId}@${ref} on ${target} with image=${image} tag=${refName} platforms=${platforms}.`);