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.
This commit is contained in:
1 parent
b62a6edd37
commit
5a5b9d13d1
1 file changed
+22
-10
@@ -18,6 +18,9 @@ jobs:
|
||||
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: |
|
||||
@@ -29,19 +32,28 @@ jobs:
|
||||
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';
|
||||
|
||||
await github.rest.repos.createDispatchEvent({
|
||||
// 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,
|
||||
event_type: 'snowluma-tag-release',
|
||||
client_payload: {
|
||||
snowluma_repository: context.repo.owner + '/' + context.repo.repo,
|
||||
snowluma_ref: context.ref,
|
||||
snowluma_ref_name: refName,
|
||||
snowluma_sha: context.sha,
|
||||
docker_image: image,
|
||||
docker_tag: refName,
|
||||
workflow_id: workflowId,
|
||||
ref,
|
||||
inputs: {
|
||||
image,
|
||||
tag: refName,
|
||||
push: 'true',
|
||||
platforms,
|
||||
},
|
||||
});
|
||||
|
||||
core.info(`Dispatched Docker release for ${context.ref} to ${target}.`);
|
||||
core.info(`Dispatched ${workflowId}@${ref} on ${target} with image=${image} tag=${refName} platforms=${platforms}.`);
|
||||
Reference in new issue
Block a user