Skip to content

Commit f9153a0

Browse files
committed
Pin workflows to the status bar
1 parent 8d4fdb7 commit f9153a0

9 files changed

Lines changed: 344 additions & 37 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to the "vscode-github-actions" extension will be documented
44

55
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
66

7+
## [v0.3.0]
8+
- Enable pinning workflows
9+
710
## [v0.2.0]
811
- Bugfix for displaying self-hosted runners
912

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,29 @@ If a workflow uses `repository_dispatch` as a trigger, you can start a new workf
3232

3333
![](./media/rdispatch.gif)
3434

35+
### Pin workflows and see their status updated automatically
36+
37+
You can pin workflows to the status bar per workspace, and automatically see the status of the most recent run. For example, to see if the change you just pushed passes the CI Build:
38+
![](./media/pin-workflows.gif)
39+
40+
1. To setup, configure the `"github-actions.workflows.pinned.workflows"` property on a global level, or per workspace (`.vscode/settings.json`):
41+
42+
```json
43+
{
44+
"github-actions.workflows.pinned.workflows": [".github/workflows/build.yml", ".github/workflows/create.yml"],
45+
}
46+
```
47+
48+
2. To enable auto-refresh via polling, set `refresh.enabled` to `true`. This works by polling the workflow runs API with a default interval of `30` seconds. You can customized the interal via `refresh.interval`:
49+
50+
```json
51+
{
52+
"github-actions.workflows.pinned.workflows": [".github/workflows/build.yml", ".github/workflows/create.yml"],
53+
"github-actions.workflows.pinned.refresh.enabled": true,
54+
"github-actions.workflows.pinned.refresh.interval": 65,
55+
}
56+
```
57+
58+
3559
## Known issues
3660

media/pin-workflows.gif

183 KB
Loading

package-lock.json

Lines changed: 30 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"url": "https://github.com/cschleiden/vscode-github-actions"
88
},
99
"description": "See GitHub Actions workflows and runs for github.com hosted repositories in VS Code",
10-
"version": "0.2.0",
10+
"version": "0.3.0",
1111
"engines": {
12-
"vscode": "^1.41.0"
12+
"vscode": "^1.44.0"
1313
},
1414
"categories": [
1515
"Other"
@@ -18,13 +18,35 @@
1818
"onCommand:auth.login",
1919
"onView:workflows",
2020
"onView:settings",
21-
"onCommand:explorer.refresh"
21+
"workspaceContains:**/.github/workflows/**"
2222
],
2323
"main": "./dist/extension",
2424
"extensionDependencies": [
2525
"vscode.git"
2626
],
2727
"contributes": {
28+
"configuration": {
29+
"title": "GitHub Actions",
30+
"properties": {
31+
"github-actions.workflows.pinned.workflows": {
32+
"description": "Workflows to show in the status bar, identified by their paths",
33+
"type": "array",
34+
"scope": "window"
35+
},
36+
"github-actions.workflows.pinned.refresh.enabled": {
37+
"type": "boolean",
38+
"description": "Auto-refresh pinned workflows. Note: this uses polling and counts against your GitHub API rate limit",
39+
"default": false,
40+
"scope": "window"
41+
},
42+
"github-actions.workflows.pinned.refresh.interval": {
43+
"type": "number",
44+
"description": "Time to wait between calls to update pinned workflows in seconds",
45+
"default": 30,
46+
"scope": "window"
47+
}
48+
}
49+
},
2850
"commands": [
2951
{
3052
"command": "auth.login",
@@ -210,7 +232,6 @@
210232
]
211233
}
212234
},
213-
"enableProposedApi": true,
214235
"scripts": {
215236
"clean": "rimraf ./dist ./out",
216237
"compile": "tsc -p ./",
@@ -228,7 +249,7 @@
228249
"@types/mocha": "^5.2.7",
229250
"@types/node": "^12.11.7",
230251
"@types/uuid": "^3.4.6",
231-
"@types/vscode": "^1.41.0",
252+
"@types/vscode": "1.44.0",
232253
"@types/yaml": "^1.2.0",
233254
"glob": "^7.1.5",
234255
"mocha": "^6.2.2",
@@ -237,7 +258,7 @@
237258
"ts-loader": "^6.2.1",
238259
"tslint": "^5.20.0",
239260
"typescript": "^3.6.4",
240-
"vsce": "^1.71.0",
261+
"vsce": "1.75.0",
241262
"vscode-test": "^1.2.2",
242263
"webpack": "^4.41.5",
243264
"webpack-cli": "^3.3.10"

src/configuration/configuration.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import * as vscode from "vscode";
2+
3+
const settingsKey = "github-actions";
4+
5+
export function initConfiguration(context: vscode.ExtensionContext) {
6+
context.subscriptions.push(
7+
vscode.workspace.onDidChangeConfiguration((e) => {
8+
if (e.affectsConfiguration(getSettingsKey("workflows.pinned"))) {
9+
pinnedWorkflowsChangeHandlers.forEach((h) => h());
10+
}
11+
})
12+
);
13+
}
14+
15+
function getConfiguration() {
16+
return vscode.workspace.getConfiguration();
17+
}
18+
19+
function getSettingsKey(settingsPath: string): string {
20+
return `${settingsKey}.${settingsPath}`;
21+
}
22+
23+
const pinnedWorkflowsChangeHandlers: (() => void)[] = [];
24+
export function onPinnedWorkflowsChange(handler: () => void) {
25+
pinnedWorkflowsChangeHandlers.push(handler);
26+
}
27+
28+
export function getPinnedWorkflows(): string[] {
29+
return getConfiguration().get<string[]>(
30+
getSettingsKey("workflows.pinned.workflows"),
31+
[]
32+
);
33+
}
34+
35+
export function isPinnedWorkflowsRefreshEnabled(): boolean {
36+
return getConfiguration().get<boolean>(
37+
getSettingsKey("workflows.pinned.refresh.enabled"),
38+
false
39+
);
40+
}
41+
42+
export function pinnedWorkflowsRefreshInterval(): number {
43+
return getConfiguration().get<number>(
44+
getSettingsKey("workflows.pinned.refresh.interval"),
45+
60
46+
);
47+
}

src/extension.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Octokit } from "@octokit/rest";
22
import * as vscode from "vscode";
33
import { setPAT } from "./auth/pat";
4+
import { initConfiguration } from "./configuration/configuration";
45
import { Protocol } from "./external/protocol";
56
import { getGitHubUrl } from "./git/repository";
67
import { LogScheme } from "./logs/constants";
@@ -17,6 +18,7 @@ import {
1718
WorkflowRun,
1819
WorkflowStep,
1920
} from "./model";
21+
import { initPinnedWorkflows } from "./pinnedWorkflows/pinnedWorkflows";
2022
import { encodeSecret } from "./secrets";
2123
import { initResources } from "./treeViews/icons";
2224
import { SettingsTreeProvider } from "./treeViews/settings";
@@ -27,11 +29,14 @@ import {
2729
} from "./workflow/workflow";
2830

2931
export function activate(context: vscode.ExtensionContext) {
30-
// TODO: Remove
32+
// Prefetch git repository origin url
3133
getGitHubUrl();
3234

3335
initResources(context);
3436

37+
initConfiguration(context);
38+
initPinnedWorkflows(context);
39+
3540
// Actions Explorer
3641
const workflowTreeProvider = new WorkflowsTreeProvider();
3742
context.subscriptions.push(

0 commit comments

Comments
 (0)