@@ -43,6 +43,22 @@ export function registerTriggerWorkflowRun(context: vscode.ExtensionContext) {
4343 return ;
4444 }
4545
46+ const relativeWorkflowPath = vscode . workspace . asRelativePath ( workflowUri , false ) ;
47+ let latestRunId : number | undefined ;
48+ try {
49+ const result = await gitHubRepoContext . client . actions . listWorkflowRuns ( {
50+ owner : gitHubRepoContext . owner ,
51+ repo : gitHubRepoContext . name ,
52+ workflow_id : relativeWorkflowPath ,
53+ per_page : 1
54+ } ) ;
55+ latestRunId = result . data . workflow_runs [ 0 ] ?. id ;
56+ } catch ( e ) {
57+ // Ignore error
58+ }
59+
60+ let dispatched = false ;
61+
4662 let selectedEvent : string | undefined ;
4763 if ( workflow . events . workflow_dispatch !== undefined && workflow . events . repository_dispatch !== undefined ) {
4864 selectedEvent = await vscode . window . showQuickPick ( [ "repository_dispatch" , "workflow_dispatch" ] , {
@@ -85,8 +101,6 @@ export function registerTriggerWorkflowRun(context: vscode.ExtensionContext) {
85101 }
86102
87103 try {
88- const relativeWorkflowPath = vscode . workspace . asRelativePath ( workflowUri , false ) ;
89-
90104 await gitHubRepoContext . client . actions . createWorkflowDispatch ( {
91105 owner : gitHubRepoContext . owner ,
92106 repo : gitHubRepoContext . name ,
@@ -95,6 +109,7 @@ export function registerTriggerWorkflowRun(context: vscode.ExtensionContext) {
95109 inputs
96110 } ) ;
97111
112+ dispatched = true ;
98113 vscode . window . setStatusBarMessage ( `GitHub Actions: Workflow event dispatched` , 2000 ) ;
99114 } catch ( error ) {
100115 return vscode . window . showErrorMessage ( `Could not create workflow dispatch: ${ ( error as Error ) ?. message } ` ) ;
@@ -134,10 +149,37 @@ export function registerTriggerWorkflowRun(context: vscode.ExtensionContext) {
134149 client_payload : { }
135150 } ) ;
136151
152+ dispatched = true ;
137153 vscode . window . setStatusBarMessage ( `GitHub Actions: Repository event '${ event_type } ' dispatched` , 2000 ) ;
138154 }
139155 }
140156
157+ if ( dispatched ) {
158+ vscode . window . withProgress ( {
159+ location : vscode . ProgressLocation . Window ,
160+ title : "Waiting for workflow run to start..."
161+ } , async ( ) => {
162+ for ( let i = 0 ; i < 20 ; i ++ ) {
163+ await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
164+ try {
165+ const result = await gitHubRepoContext . client . actions . listWorkflowRuns ( {
166+ owner : gitHubRepoContext . owner ,
167+ repo : gitHubRepoContext . name ,
168+ workflow_id : relativeWorkflowPath ,
169+ per_page : 1
170+ } ) ;
171+ const newLatestRunId = result . data . workflow_runs [ 0 ] ?. id ;
172+ if ( newLatestRunId && newLatestRunId !== latestRunId ) {
173+ await vscode . commands . executeCommand ( "github-actions.explorer.refresh" ) ;
174+ break ;
175+ }
176+ } catch ( e ) {
177+ // Ignore
178+ }
179+ }
180+ } ) ;
181+ }
182+
141183 return vscode . commands . executeCommand ( "github-actions.explorer.refresh" ) ;
142184 }
143185 )
0 commit comments