@@ -7,7 +7,6 @@ async function run(): Promise<void> {
77 // Required inputs
88 const token = core . getInput ( 'token' )
99 const workflowReference = core . getInput ( 'workflow' )
10- const workflowIdFlag = core . getInput ( 'use-workflow-id' ) || 'false'
1110 // Optional inputs, with defaults
1211 const ref = core . getInput ( 'ref' ) || github . context . ref
1312 const repo = core . getInput ( 'repo' ) || `${ github . context . repo . owner } /${ github . context . repo . repo } `
@@ -22,33 +21,27 @@ async function run(): Promise<void> {
2221 // Get octokit client for making API calls
2322 const octokit = github . getOctokit ( token )
2423
25- let workflowId = ''
26- if ( workflowIdFlag !== 'true' ) {
27- // List workflows via API
28- const listResp = await octokit . request ( `GET /repos/${ repo } /actions/workflows` , {
29- ref : ref ,
30- inputs : inputs
31- } )
32- if ( listResp . status != 200 ) throw new Error ( `Got HTTP ${ listResp . status } calling list workflows API 💩` )
33-
34- // Debug response if ACTIONS_STEP_DEBUG is enabled
35- core . debug ( listResp . data )
36-
37- // Locate workflow by name as we need it's id
38- const foundWorkflow = listResp . data . workflows . find ( ( wf : Record < string , string > ) => {
39- return wf [ 'name' ] === workflowReference
40- } )
41- if ( ! foundWorkflow ) throw new Error ( `Unable to find workflow named '${ workflowReference } ' in ${ repo } 😥` )
42-
43- workflowId = foundWorkflow . id
44- } else {
45- workflowId = workflowReference
46- }
24+ // List workflows via API
25+ const listResp = await octokit . request ( `GET /repos/${ repo } /actions/workflows` , {
26+ ref : ref ,
27+ inputs : inputs
28+ } )
29+ if ( listResp . status != 200 ) throw new Error ( `Got HTTP ${ listResp . status } calling list workflows API 💩` )
30+
31+ // Debug response if ACTIONS_STEP_DEBUG is enabled
32+ core . debug ( listResp . data )
33+
34+ // Locate workflow by name as we need it's id
35+ const foundWorkflow = listResp . data . workflows . find ( ( wf : Record < string , string > ) => {
36+ // Match on name or id
37+ return ( wf [ 'name' ] === workflowReference || wf [ 'id' ] === workflowReference )
38+ } )
39+ if ( ! foundWorkflow ) throw new Error ( `Unable to find workflow '${ workflowReference } ' in ${ repo } 😥` )
4740
48- console . log ( `Workflow id is: ${ workflowId } ` )
41+ console . log ( `Workflow id is: ${ foundWorkflow . id } ` )
4942
5043 // Call workflow_dispatch API
51- const dispatchResp = await octokit . request ( `POST /repos/${ repo } /actions/workflows/${ workflowId } /dispatches` , {
44+ const dispatchResp = await octokit . request ( `POST /repos/${ repo } /actions/workflows/${ foundWorkflow . id } /dispatches` , {
5245 ref : ref ,
5346 inputs : inputs
5447 } )
0 commit comments