Skip to content

Commit 249d9cd

Browse files
committed
Support workflow_dispatch trigger in release workflow
The release workflow was only designed for workflow_run triggers, causing errors when manually triggered via workflow_dispatch. Changes: 1. Handle both trigger types when getting commit SHA: - workflow_run: use context.payload.workflow_run.head_sha - workflow_dispatch: use context.sha 2. Updated job conditions to accept both triggers: - workflow_dispatch (manual trigger) - workflow_run (automatic trigger after other workflows) This allows manual testing of the release workflow, which is essential for fork PRs where workflow_run doesn't trigger due to GitHub's security restrictions. Now you can manually trigger the release workflow to test it!
1 parent bcdf060 commit 249d9cd

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,17 @@ jobs:
2828
with:
2929
script: |
3030
const requiredWorkflows = ['wheels', 'wheels-docker', 'wheels-arm64', 'wstest', 'main'];
31-
const commitSha = context.payload.workflow_run.head_sha;
31+
32+
// Handle both workflow_run and workflow_dispatch triggers
33+
const commitSha = context.payload.workflow_run?.head_sha || context.sha;
34+
const triggeredBy = context.payload.workflow_run?.name || 'manual (workflow_dispatch)';
3235
3336
console.log('─────────────────────────────────────────────────');
3437
console.log('🔍 Checking workflow completion status');
3538
console.log('─────────────────────────────────────────────────');
39+
console.log(`Event: ${context.eventName}`);
3640
console.log(`Commit SHA: ${commitSha}`);
37-
console.log(`Triggered by: ${context.payload.workflow_run.name}`);
41+
console.log(`Triggered by: ${triggeredBy}`);
3842
console.log('');
3943
4044
// Get all workflow runs for this commit
@@ -104,8 +108,8 @@ jobs:
104108
# Only create releases for development builds (explicit positive list)
105109
if: |
106110
needs.check-all-workflows.outputs.all_complete == 'true' &&
107-
github.event_name == 'workflow_run' &&
108-
github.event.workflow_run.conclusion == 'success' &&
111+
(github.event_name == 'workflow_dispatch' ||
112+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')) &&
109113
needs.identifiers.outputs.release_type == 'development'
110114
111115
env:
@@ -289,8 +293,8 @@ jobs:
289293
# Only create releases for nightly and stable builds (explicit positive list)
290294
if: |
291295
needs.check-all-workflows.outputs.all_complete == 'true' &&
292-
github.event_name == 'workflow_run' &&
293-
github.event.workflow_run.conclusion == 'success' &&
296+
(github.event_name == 'workflow_dispatch' ||
297+
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')) &&
294298
(needs.identifiers.outputs.release_type == 'nightly' || needs.identifiers.outputs.release_type == 'stable')
295299
296300
env:

0 commit comments

Comments
 (0)