@@ -350,7 +350,8 @@ class GitHubHelper {
350
350
}
351
351
createWorkflowDispatch(cmd, clientPayload) {
352
352
return __awaiter(this, void 0, void 0, function* () {
353
- const workflow = `${cmd.command}${cmd.event_type_suffix}.yml`;
353
+ const workflowName = `${cmd.command}${cmd.event_type_suffix}`;
354
+ const workflow = yield this.getWorkflow(cmd.repository, workflowName);
354
355
const slashCommand = clientPayload.slash_command;
355
356
const ref = slashCommand.args.named.ref
356
357
? slashCommand.args.named.ref
@@ -366,8 +367,21 @@ class GitHubHelper {
366
367
if (count == 10)
367
368
break;
368
369
}
369
- yield this.octokit.request('POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches', Object.assign(Object.assign({}, this.parseRepository(cmd.repository)), { workflow_id: workflow, ref: ref, inputs: inputs }));
370
- core.info(`Command '${cmd.command}' dispatched to workflow '${workflow}' in '${cmd.repository}'`);
370
+ yield this.octokit.request('POST /repos/{owner}/{repo}/actions/workflows/{workflow}/dispatches', Object.assign(Object.assign({}, this.parseRepository(cmd.repository)), { workflow: workflow, ref: ref, inputs: inputs }));
371
+ core.info(`Command '${cmd.command}' dispatched to workflow '${workflowName}' in '${cmd.repository}'`);
372
+ });
373
+ }
374
+ getWorkflow(repository, workflowName) {
375
+ return __awaiter(this, void 0, void 0, function* () {
376
+ core.debug(`Getting workflow ${workflowName} for repository ${repository}`);
377
+ const { data: workflows } = yield this.octokit.rest.actions.listRepoWorkflows(Object.assign({}, this.parseRepository(repository)));
378
+ for (const workflow of workflows.workflows) {
379
+ if (workflow.path === `${workflowName}.yml` || workflow.path === `${workflowName}.yaml`) {
380
+ core.info(`Selecting workflow file ${workflow.path}`);
381
+ return workflow.path;
382
+ }
383
+ }
384
+ throw new Error(`Workflow ${workflowName} not found`);
371
385
});
372
386
}
373
387
getDefaultBranch(repository) {
0 commit comments