@@ -149,6 +149,8 @@ private async Task LoadDataAsync()
149149 await RefreshSecretsAsync ( client ) ;
150150 // get environments
151151 await RefreshEnvironmentsAsync ( client ) ;
152+ // get workflows
153+ await RefreshWorkflowsAsync ( client ) ;
152154
153155 // get current branch
154156 var runs = await client . Actions ? . Workflows ? . Runs ? . List ( _repoInfo . RepoOwner , _repoInfo . RepoName , new WorkflowRunsRequest ( ) { Branch = _repoInfo . CurrentBranch } , new ApiOptions ( ) { PageCount = 1 , PageSize = maxRuns } ) ;
@@ -271,6 +273,11 @@ private async Task RefreshEnvironmentsAsync(GitHubClient client)
271273 tvEnvironments . ItemsSource = envList ;
272274 }
273275
276+ private async Task RefreshWorkflowsAsync ( GitHubClient client )
277+ {
278+ var workflows = await client . Actions ? . Workflows ? . List ( _repoInfo . RepoOwner , _repoInfo . RepoName ) ;
279+ tvWorkflows . ItemsSource = workflows . Workflows ;
280+ }
274281 private async Task RefreshSecretsAsync ( GitHubClient client )
275282 {
276283 var repoSecrets = await client . Repository ? . Actions ? . Secrets ? . GetAll ( _repoInfo . RepoOwner , _repoInfo . RepoName ) ;
@@ -419,5 +426,27 @@ private void ViewLog_Click(object sender, RoutedEventArgs e)
419426 Process . Start ( logUrl ) ;
420427 }
421428 }
429+
430+ private void RunWorkflow_Click ( object sender , RoutedEventArgs e )
431+ {
432+ MenuItem menuItem = ( MenuItem ) sender ;
433+ TextBlock tvi = GetParentTreeViewItem ( menuItem ) ;
434+
435+ // check the tag value to ensure it isn't null
436+ if ( tvi is not null && tvi . Tag is not null )
437+ {
438+ GitHubClient client = GetGitHubClient ( ) ;
439+ CreateWorkflowDispatch cwd = new CreateWorkflowDispatch ( _repoInfo . CurrentBranch ) ;
440+
441+ try
442+ {
443+ _ = client . Actions . Workflows . CreateDispatch ( _repoInfo . RepoOwner , _repoInfo . RepoName , ( long ) tvi . Tag , cwd ) ;
444+ }
445+ catch ( Exception ex )
446+ {
447+ Debug . WriteLine ( $ "Failed to start workflow: { ex . Message } ") ;
448+ }
449+ }
450+ }
422451}
423452
0 commit comments