Skip to content

Commit 8bf729f

Browse files
Merge pull request #170 from github/ketchup-lrotschy/show-step-logs
Add a globe icon to workflow steps that links to the GitHub.com specific step
2 parents 5340397 + b3c8678 commit 8bf729f

3 files changed

Lines changed: 41 additions & 1 deletion

File tree

package.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,20 @@
140140
{
141141
"command": "github-actions.workflow.logs",
142142
"category": "GitHub Actions",
143-
"title": "View logs",
143+
"title": "View job logs",
144144
"when": "viewItem =~ /job/",
145145
"icon": {
146146
"dark": "resources/icons/dark/logs.svg",
147147
"light": "resources/icons/light/logs.svg"
148148
}
149149
},
150+
{
151+
"command": "github-actions.step.logs",
152+
"category": "GitHub Actions",
153+
"title": "View step logs",
154+
"when": "viewItem =~ /step/",
155+
"icon": "$(globe)"
156+
},
150157
{
151158
"command": "github-actions.workflow.run.rerun",
152159
"category": "GitHub Actions",
@@ -363,6 +370,11 @@
363370
"group": "inline",
364371
"when": "viewItem =~ /job/ && viewItem =~ /completed/"
365372
},
373+
{
374+
"command": "github-actions.step.logs",
375+
"group": "inline",
376+
"when": "viewItem =~ /step/ && viewItem =~ /completed/"
377+
},
366378
{
367379
"command": "github-actions.workflow.run.cancel",
368380
"when": "viewItem =~ /run/ && viewItem =~ /cancelable/"
@@ -438,6 +450,10 @@
438450
"command": "github-actions.workflow.logs",
439451
"when": "false"
440452
},
453+
{
454+
"command": "github-actions.step.logs",
455+
"when": "false"
456+
},
441457
{
442458
"command": "github-actions.workflow.run.rerun",
443459
"when": "false"
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as vscode from "vscode";
2+
import {WorkflowStepNode} from "../treeViews/workflows/workflowStepNode";
3+
4+
type WorkflowStepCommandArgs = Pick<WorkflowStepNode, "job" | "step" | "gitHubRepoContext">;
5+
6+
export function registerOpenWorkflowStepLogs(context: vscode.ExtensionContext) {
7+
context.subscriptions.push(
8+
vscode.commands.registerCommand("github-actions.step.logs", async (args: WorkflowStepCommandArgs) => {
9+
const job = args.job.job;
10+
let url = job.html_url ?? "";
11+
const stepName = args.step.name;
12+
13+
const index = job.steps && job.steps.findIndex(step => step.name === stepName) + 1;
14+
15+
if (url && index) {
16+
url = url + "#step:" + index.toString() + ":1";
17+
}
18+
19+
await vscode.env.openExternal(vscode.Uri.parse(url));
20+
})
21+
);
22+
}

src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {getSession} from "./auth/auth";
55
import {registerCancelWorkflowRun} from "./commands/cancelWorkflowRun";
66
import {registerOpenWorkflowFile} from "./commands/openWorkflowFile";
77
import {registerOpenWorkflowJobLogs} from "./commands/openWorkflowJobLogs";
8+
import {registerOpenWorkflowStepLogs} from "./commands/openWorkflowStepLogs";
89
import {registerOpenWorkflowRun} from "./commands/openWorkflowRun";
910
import {registerPinWorkflow} from "./commands/pinWorkflow";
1011
import {registerReRunWorkflowRun} from "./commands/rerunWorkflowRun";
@@ -71,6 +72,7 @@ export async function activate(context: vscode.ExtensionContext) {
7172
registerOpenWorkflowRun(context);
7273
registerOpenWorkflowFile(context);
7374
registerOpenWorkflowJobLogs(context);
75+
registerOpenWorkflowStepLogs(context);
7476
registerTriggerWorkflowRun(context);
7577
registerReRunWorkflowRun(context);
7678
registerCancelWorkflowRun(context);

0 commit comments

Comments
 (0)