-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathcancelWorkflowRun.ts
More file actions
24 lines (21 loc) · 898 Bytes
/
cancelWorkflowRun.ts
File metadata and controls
24 lines (21 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import * as vscode from "vscode";
import {WorkflowRunCommandArgs} from "../treeViews/shared/workflowRunNode";
export function registerCancelWorkflowRun(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand("github-actions.workflow.run.cancel", async (args: WorkflowRunCommandArgs) => {
const gitHubRepoContext = args.gitHubRepoContext;
const run = args.run;
try {
await gitHubRepoContext.client.actions.cancelWorkflowRun({
owner: gitHubRepoContext.owner,
repo: gitHubRepoContext.name,
run_id: run.run.id
});
} catch (e) {
await vscode.window.showErrorMessage(`Could not cancel workflow: '${(e as Error).message}'`);
}
// Start refreshing the run to reflect cancellation in UI
args.store.pollRun(run.run.id, gitHubRepoContext, 1000, 10);
})
);
}