Fix act not found when installed as github cli extension

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2024-11-24 23:40:47 -05:00
parent 76ad59a213
commit b0e07549a6
3 changed files with 23 additions and 2 deletions

View File

@@ -685,6 +685,11 @@
"configuration": {
"title": "GitHub Local Actions",
"properties": {
"githubLocalActions.actCommand": {
"markdownDescription": "The base `nektos/act` command to be called. By default, this will be `act` (requires the binary to be on your `PATH`). If the binary is not on your `PATH`, the command can be fully qualified. If `act` is installed as a GitHub CLI extension, this command should be set to `gh act`.",
"type": "string",
"default": "act"
},
"githubLocalActions.dockerDesktopPath": {
"type": "string",
"markdownDescription": "The path to your Docker Desktop executable (used for Windows and MacOS). To start Docker Engine from the `Components` view, this application will be launched. Refer to the default path based on OS:\n\n* **Windows**: `C:/Program Files/Docker/Docker/Docker Desktop.exe`\n\n* **MacOS**: `/Applications/Docker.app`",

View File

@@ -2,6 +2,7 @@ import * as path from "path";
import sanitize from "sanitize-filename";
import { ExtensionContext, ShellExecution, TaskGroup, TaskPanelKind, TaskRevealKind, tasks, TaskScope, Uri, window, workspace, WorkspaceFolder } from "vscode";
import { ComponentsManager } from "./componentsManager";
import { ConfigurationManager, Section } from "./configurationManager";
import { componentsTreeDataProvider, historyTreeDataProvider } from './extension';
import { HistoryManager, HistoryStatus } from './historyManager';
import { SecretManager } from "./secretManager";
@@ -66,7 +67,8 @@ export interface CommandArgs {
}
export class Act {
private static base: string = 'act';
static command: string = 'act';
static githubCliCommand: string = 'act';
context: ExtensionContext;
storageManager: StorageManager;
secretManager: SecretManager;
@@ -305,10 +307,11 @@ export class Act {
} catch (error: any) { }
// Build command with settings
const actCommand = ConfigurationManager.get<string>(Section.actCommand) || Act.command;
const settings = await this.settingsManager.getSettings(workspaceFolder, true);
const command =
`set -o pipefail; ` +
`${Act.base} ${commandArgs.options}` +
`${actCommand} ${commandArgs.options}` +
(settings.secrets.length > 0 ? ` ${Option.Secret} ${settings.secrets.map(secret => secret.key).join(` ${Option.Secret} `)}` : ``) +
(settings.secretFiles.length > 0 ? ` ${Option.SecretFile} "${settings.secretFiles[0].path}"` : ` ${Option.SecretFile} ""`) +
(settings.variables.length > 0 ? ` ${Option.Variable} ${settings.variables.map(variable => (variable.value ? `${variable.key}=${variable.value}` : variable.key)).join(` ${Option.Variable} `)}` : ``) +
@@ -386,6 +389,12 @@ export class Act {
group: TaskGroup.Build,
execution: new ShellExecution(command)
});
if (command.includes('gh-act')) {
ConfigurationManager.set(Section.actCommand, Act.command);
} else {
ConfigurationManager.set(Section.actCommand, Act.githubCliCommand);
}
}
}
}

View File

@@ -1,4 +1,5 @@
import { ConfigurationTarget, workspace } from 'vscode';
import { Act } from './act';
export enum Platform {
windows = 'win32',
@@ -7,6 +8,7 @@ export enum Platform {
}
export enum Section {
actCommand = 'actCommand',
dockerDesktopPath = 'dockerDesktopPath'
}
@@ -30,6 +32,11 @@ export namespace ConfigurationManager {
ConfigurationManager.set(Section.dockerDesktopPath, dockerDesktopPath);
}
let actCommand = ConfigurationManager.get<string>(Section.actCommand);
if (!actCommand) {
ConfigurationManager.set(Section.actCommand, Act.command);
}
}
export function getSearchTerm(section: Section): string {