Skip to content

Commit bf974bc

Browse files
fix: apply code build script
1 parent eaaecc6 commit bf974bc

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

dist/index.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,16 +293,24 @@ function workflowDispatch(distinctId) {
293293
if (!config.ref) {
294294
throw new Error(`workflow_dispatch: An input to 'ref' was not provided`);
295295
}
296-
// https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
297-
const response = yield octokit.rest.actions.createWorkflowDispatch({
296+
// GitHub released a breaking change to the createWorkflowDispatch API that resulted in a change where the returned
297+
// status code changed to 200, from 204. At the time, the @octokit/types had not been updated to reflect this change.
298+
//
299+
// Given that we are in an interim state where the API behaviour, but the public documentation has not been updated
300+
// to reflect this change, and GitHub has not yet released any updates on this topic. I can going to play the safe
301+
// route and assume that the response status code could be either 200 or 204.
302+
//
303+
// Reference: https://github.com/orgs/community/discussions/9752#discussioncomment-15295321
304+
// Documentation: https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
305+
const response = (yield octokit.rest.actions.createWorkflowDispatch({
298306
owner: config.owner,
299307
repo: config.repo,
300308
workflow_id: config.workflow,
301309
ref: config.ref,
302310
inputs
303-
});
304-
if (response.status !== 204) {
305-
throw new Error(`workflow_dispatch: Failed to dispatch action, expected 204 but received ${response.status}`);
311+
}));
312+
if (response.status !== 200 && response.status !== 204) {
313+
throw new Error(`workflow_dispatch: Failed to dispatch action, expected 200 or 204 but received ${response.status}`);
306314
}
307315
core.info(`✅ Successfully dispatched workflow using workflow_dispatch method:
308316
repository: ${config.owner}/${config.repo}

0 commit comments

Comments
 (0)