29
package.json
29
package.json
@@ -72,6 +72,12 @@
|
|||||||
"title": "Run All Workflows",
|
"title": "Run All Workflows",
|
||||||
"icon": "$(run-all)"
|
"icon": "$(run-all)"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"category": "GitHub Local Actions",
|
||||||
|
"command": "githubLocalActions.runEvent",
|
||||||
|
"title": "Run Event",
|
||||||
|
"icon": "$(symbol-event)"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"category": "GitHub Local Actions",
|
"category": "GitHub Local Actions",
|
||||||
"command": "githubLocalActions.refreshWorkflows",
|
"command": "githubLocalActions.refreshWorkflows",
|
||||||
@@ -107,6 +113,10 @@
|
|||||||
"command": "githubLocalActions.runAllWorkflows",
|
"command": "githubLocalActions.runAllWorkflows",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.runEvent",
|
||||||
|
"when": "never"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.refreshWorkflows",
|
"command": "githubLocalActions.refreshWorkflows",
|
||||||
"when": "never"
|
"when": "never"
|
||||||
@@ -136,10 +146,15 @@
|
|||||||
"group": "navigation@0"
|
"group": "navigation@0"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.refreshWorkflows",
|
"command": "githubLocalActions.runEvent",
|
||||||
"when": "view == workflows",
|
"when": "view == workflows",
|
||||||
"group": "navigation@1"
|
"group": "navigation@1"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "githubLocalActions.refreshWorkflows",
|
||||||
|
"when": "view == workflows",
|
||||||
|
"group": "navigation@2"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "githubLocalActions.refreshSettings",
|
"command": "githubLocalActions.refreshSettings",
|
||||||
"when": "view == settings",
|
"when": "view == settings",
|
||||||
@@ -161,24 +176,24 @@
|
|||||||
},
|
},
|
||||||
"colors": [
|
"colors": [
|
||||||
{
|
{
|
||||||
"id": "GitHubLocalActions.enabled",
|
"id": "GitHubLocalActions.green",
|
||||||
"description": "Color for a component success state",
|
"description": "Color for green in GitHub Local Actions extension",
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"dark": "#89d185",
|
"dark": "#89d185",
|
||||||
"light": "#89d185"
|
"light": "#89d185"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "GitHubLocalActions.warning",
|
"id": "GitHubLocalActions.yellow",
|
||||||
"description": "Color for a component warning state",
|
"description": "Color for yellow in GitHub Local Actions extension",
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"dark": "#cca700",
|
"dark": "#cca700",
|
||||||
"light": "#cca700"
|
"light": "#cca700"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "GitHubLocalActions.disabled",
|
"id": "GitHubLocalActions.red",
|
||||||
"description": "Color for a component disabled state",
|
"description": "Color for red in GitHub Local Actions extension",
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"dark": "#f48771",
|
"dark": "#f48771",
|
||||||
"light": "#f48771"
|
"light": "#f48771"
|
||||||
|
|||||||
54
src/act.ts
54
src/act.ts
@@ -1,9 +1,45 @@
|
|||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import { commands, ShellExecution, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, window, workspace } from "vscode";
|
import { commands, ShellExecution, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, TaskScope, window } from "vscode";
|
||||||
import { ComponentManager } from "./componentManager";
|
import { ComponentManager } from "./componentManager";
|
||||||
import { Workflow } from "./workflowManager";
|
import { Workflow } from "./workflowManager";
|
||||||
|
|
||||||
export enum Options {
|
export enum EventTrigger {
|
||||||
|
BranchProtectionRule = 'branch_protection_rule',
|
||||||
|
CheckRun = 'check_run',
|
||||||
|
CheckSuite = 'check_suite',
|
||||||
|
Create = 'create',
|
||||||
|
Delete = 'delete',
|
||||||
|
Deployment = 'deployment',
|
||||||
|
DeploymentStatus = 'deployment_status',
|
||||||
|
Discussion = 'discussion',
|
||||||
|
DiscussionComment = 'discussion_comment',
|
||||||
|
Fork = 'fork',
|
||||||
|
Gollum = 'gollum',
|
||||||
|
IssueComment = 'issue_comment',
|
||||||
|
Issues = 'issues',
|
||||||
|
Label = 'label',
|
||||||
|
MergeGroup = 'merge_group',
|
||||||
|
Milestone = 'milestone',
|
||||||
|
PageBuild = 'page_build',
|
||||||
|
Public = 'public',
|
||||||
|
PullRequest = 'pull_request',
|
||||||
|
PullRequestComment = 'pull_request_comment',
|
||||||
|
PullRequestReview = 'pull_request_review',
|
||||||
|
PullRequestReviewComment = 'pull_request_review_comment',
|
||||||
|
PullRequestTarget = 'pull_request_target',
|
||||||
|
Push = 'push',
|
||||||
|
RegistryPackage = 'registry_package',
|
||||||
|
Release = 'release',
|
||||||
|
RepositoryDispatch = 'repository_dispatch',
|
||||||
|
Schedule = 'schedule',
|
||||||
|
Status = 'status',
|
||||||
|
Watch = 'watch',
|
||||||
|
WorkflowCall = 'workflow_call',
|
||||||
|
WorkflowDispatch = 'workflow_dispatch',
|
||||||
|
WorkflowRun = 'workflow_run'
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum Option {
|
||||||
Workflows = '-W'
|
Workflows = '-W'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,11 +50,15 @@ export class Act {
|
|||||||
// TODO: Implement
|
// TODO: Implement
|
||||||
}
|
}
|
||||||
|
|
||||||
static async runWorkflow(workflow: Workflow) {
|
static async runEvent(eventTrigger: EventTrigger) {
|
||||||
return await Act.runCommand(workflow, `${Act.base} ${Options.Workflows} '.github/workflows/${path.parse(workflow.uri.fsPath).base}'`);
|
return await Act.runCommand(`${Act.base} ${eventTrigger}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async runCommand(workflow: Workflow, command: string) {
|
static async runWorkflow(workflow: Workflow) {
|
||||||
|
return await Act.runCommand(`${Act.base} ${Option.Workflows} '.github/workflows/${path.parse(workflow.uri.fsPath).base}'`, workflow);
|
||||||
|
}
|
||||||
|
|
||||||
|
static async runCommand(command: string, workflow?: Workflow) {
|
||||||
|
|
||||||
const unreadyComponents = await ComponentManager.getUnreadyComponents();
|
const unreadyComponents = await ComponentManager.getUnreadyComponents();
|
||||||
if (unreadyComponents.length > 0) {
|
if (unreadyComponents.length > 0) {
|
||||||
@@ -31,11 +71,11 @@ export class Act {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await tasks.executeTask({
|
await tasks.executeTask({
|
||||||
name: workflow.name,
|
name: workflow?.name || 'act',
|
||||||
detail: 'Run workflow',
|
detail: 'Run workflow',
|
||||||
definition: { type: 'GitHub Local Actions' },
|
definition: { type: 'GitHub Local Actions' },
|
||||||
source: 'GitHub Local Actions',
|
source: 'GitHub Local Actions',
|
||||||
scope: workspace.getWorkspaceFolder(workflow.uri),
|
scope: TaskScope.Workspace,
|
||||||
isBackground: true,
|
isBackground: true,
|
||||||
presentationOptions: {
|
presentationOptions: {
|
||||||
reveal: TaskRevealKind.Always,
|
reveal: TaskRevealKind.Always,
|
||||||
|
|||||||
@@ -12,17 +12,17 @@ export class DecorationProvider implements FileDecorationProvider {
|
|||||||
if (params.get('status') === Status.Enabled) {
|
if (params.get('status') === Status.Enabled) {
|
||||||
return {
|
return {
|
||||||
badge: '✅',
|
badge: '✅',
|
||||||
color: new ThemeColor('GitHubLocalActions.enabled')
|
color: new ThemeColor('GitHubLocalActions.green')
|
||||||
};
|
};
|
||||||
} else if (params.get('status') === Status.Warning) {
|
} else if (params.get('status') === Status.Warning) {
|
||||||
return {
|
return {
|
||||||
badge: '⚠️',
|
badge: '⚠️',
|
||||||
color: new ThemeColor('GitHubLocalActions.warning')
|
color: new ThemeColor('GitHubLocalActions.yellow')
|
||||||
};
|
};
|
||||||
} else if (params.get('status') === Status.Disabled) {
|
} else if (params.get('status') === Status.Disabled) {
|
||||||
return {
|
return {
|
||||||
badge: '❌',
|
badge: '❌',
|
||||||
color: new ThemeColor('GitHubLocalActions.disabled')
|
color: new ThemeColor('GitHubLocalActions.red')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else if (uri.scheme === WorkflowTreeItem.contextValue) {
|
} else if (uri.scheme === WorkflowTreeItem.contextValue) {
|
||||||
@@ -30,7 +30,7 @@ export class DecorationProvider implements FileDecorationProvider {
|
|||||||
if (params.get('error')) {
|
if (params.get('error')) {
|
||||||
return {
|
return {
|
||||||
badge: '❌',
|
badge: '❌',
|
||||||
color: new ThemeColor('GitHubLocalActions.disabled')
|
color: new ThemeColor('GitHubLocalActions.red')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { CancellationToken, commands, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, window, workspace } from "vscode";
|
import { CancellationToken, commands, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, window, workspace } from "vscode";
|
||||||
import { Act } from "../../act";
|
import { Act, EventTrigger } from "../../act";
|
||||||
import { WorkflowManager } from "../../workflowManager";
|
import { WorkflowManager } from "../../workflowManager";
|
||||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||||
import WorkflowTreeItem from "./workflow";
|
import WorkflowTreeItem from "./workflow";
|
||||||
@@ -14,6 +14,16 @@ export default class WorkflowsTreeDataProvider implements TreeDataProvider<Githu
|
|||||||
commands.registerCommand('githubLocalActions.runAllWorkflows', async () => {
|
commands.registerCommand('githubLocalActions.runAllWorkflows', async () => {
|
||||||
await Act.runAllWorkflows();
|
await Act.runAllWorkflows();
|
||||||
}),
|
}),
|
||||||
|
commands.registerCommand('githubLocalActions.runEvent', async () => {
|
||||||
|
const event = await window.showQuickPick(Object.values(EventTrigger), {
|
||||||
|
title: 'Select the event to run',
|
||||||
|
placeHolder: 'Event'
|
||||||
|
});
|
||||||
|
|
||||||
|
if(event) {
|
||||||
|
await Act.runEvent(event as EventTrigger);
|
||||||
|
}
|
||||||
|
}),
|
||||||
commands.registerCommand('githubLocalActions.refreshWorkflows', async () => {
|
commands.registerCommand('githubLocalActions.refreshWorkflows', async () => {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user