Skip to content

Commit 4c044c1

Browse files
author
Automated Publisher
committed
Automated publish: Sun Aug 9 21:46:01 UTC 2020 ae600ac
1 parent ae600ac commit 4c044c1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

dist/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ function run() {
545545
try {
546546
// Required inputs
547547
const token = core.getInput('token');
548-
const workflowName = core.getInput('workflow');
548+
const workflowRef = core.getInput('workflow');
549549
// Optional inputs, with defaults
550550
const ref = core.getInput('ref') || github.context.ref;
551551
const [owner, repo] = core.getInput('repo')
@@ -559,16 +559,16 @@ function run() {
559559
}
560560
// Get octokit client for making API calls
561561
const octokit = github.getOctokit(token);
562-
// List workflows via API
562+
// List workflows via API, and handle paginated results
563563
const workflows = yield octokit.paginate(octokit.actions.listRepoWorkflows.endpoint.merge({ owner, repo, ref, inputs }));
564564
// Debug response if ACTIONS_STEP_DEBUG is enabled
565565
core.debug('### START List Workflows response data');
566566
core.debug(JSON.stringify(workflows, null, 3));
567567
core.debug('### END: List Workflows response data');
568-
// Locate workflow by name as we need it's id
569-
const workflowFind = workflows.find((workflow) => workflow.name === workflowName);
568+
// Locate workflow either by name or id
569+
const workflowFind = workflows.find((workflow) => workflow.name === workflowRef || workflow.id.toString() === workflowRef);
570570
if (!workflowFind)
571-
throw new Error(`Unable to find workflow named '${workflowName}' in ${owner}/${repo} 😥`);
571+
throw new Error(`Unable to find workflow '${workflowRef}' in ${owner}/${repo} 😥`);
572572
console.log(`Workflow id is: ${workflowFind.id}`);
573573
// Call workflow_dispatch API
574574
const dispatchResp = yield octokit.request(`POST /repos/${owner}/${repo}/actions/workflows/${workflowFind.id}/dispatches`, {

0 commit comments

Comments
 (0)