-
Notifications
You must be signed in to change notification settings - Fork 175
Expand file tree
/
Copy pathattachWorkflowJobDebugger.ts
More file actions
43 lines (38 loc) · 1.67 KB
/
attachWorkflowJobDebugger.ts
File metadata and controls
43 lines (38 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import * as vscode from "vscode";
import {WorkflowJobNode} from "../treeViews/shared/workflowJobNode";
import {getGitHubContext} from "../git/repository";
export type AttachWorkflowJobDebuggerArgs = Pick<WorkflowJobNode, "gitHubRepoContext" | "job">;
export function registerAttachWorkflowJobDebugger(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand(
"github-actions.workflow.job.attachDebugger",
async (args: AttachWorkflowJobDebuggerArgs) => {
const job = args.job.job;
const repoContext = args.gitHubRepoContext;
const workflowName = job.workflow_name || undefined;
const jobName = job.name;
const title = workflowName ? `Workflow "${workflowName}" job "${jobName}"` : `Job "${jobName}"`;
// Get current GitHub user
const gitHubContext = await getGitHubContext();
const username = gitHubContext?.username || "unknown";
const debugConfig: vscode.DebugConfiguration = {
name: `GitHub Actions: ${title}`,
type: "github-actions",
request: "attach",
workflowName,
jobName,
// Identity fields for DAP proxy audit logging
githubActor: username,
githubRepository: `${repoContext.owner}/${repoContext.name}`,
githubRunID: String(job.run_id),
githubJobID: String(job.id)
};
const folder = vscode.workspace.workspaceFolders?.[0];
const started = await vscode.debug.startDebugging(folder, debugConfig);
if (!started) {
await vscode.window.showErrorMessage("Failed to start GitHub Actions debug session.");
}
}
)
);
}