diff --git a/package.json b/package.json index 3c863b5..9d7a932 100644 --- a/package.json +++ b/package.json @@ -685,12 +685,159 @@ "configuration": { "title": "GitHub Local Actions", "properties": { - "githubLocalActions.dockerDesktopPath": { - "type": "string", + "githubLocalActions.dockerEngine.dockerDesktopPath": { "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`", + "type": "string", + "default": "" + }, + "githubLocalActions.act.actionCachePath": { + "description": "Defines the path where the actions get cached and host workspaces are created.", + "type": "string", + "default": "" + }, + "githubLocalActions.act.actionOfflineMode": { + "description": "If action contents exists, it will not be fetch and pull again. If turn on this, will turn off force pull.", + "type": "boolean", + "default": false + }, + "githubLocalActions.act.actor": { + "description": "User that triggered the event.", + "type": "string", + "default": "nektos/act" + }, + "githubLocalActions.act.artifactServerAddr": { + "markdownDescription": "Defines the address to which the artifact server binds. If not set, `nektos/act` will use the outbound IP address of this machine. This means that it will try to access the internet and return the local IP address of the connection. If the machine cannot access the internet, it returns a preferred IP address from network interfaces. If no IP address is found, this will not be set.", + "type": "string", + "default": "" + }, + "githubLocalActions.act.artifactServerPath": { + "description": "Defines the path where the artifact server stores uploads and retrieves downloads from. If not specified, the artifact server will not start.", + "type": "string", + "default": "" + }, + "githubLocalActions.act.artifactServerPort": { + "description": "Defines the port where the artifact server listens.", + "type": "number", + "default": 34567 + }, + "githubLocalActions.act.bind": { + "description": "Bind working directory to container, rather than copy.", + "type": "boolean", + "default": false + }, + "githubLocalActions.act.cacheServerAddr": { + "markdownDescription": "Defines the address to which the cache server binds. If not set, `nektos/act` will use the outbound IP address of this machine. This means that it will try to access the internet and return the local IP address of the connection. If the machine cannot access the internet, it returns a preferred IP address from network interfaces. If no IP address is found, this will not be set.", + "type": "string", + "default": "" + }, + "githubLocalActions.act.cacheServerPath": { + "description": "Defines the path where the cache server stores caches.", + "type": "string", + "default": "" + }, + "githubLocalActions.act.cacheServerPort": { + "markdownDescription": "Defines the port where the artifact server listens. `0` means a randomly available port.", + "type": "number", + "default": 0 + }, + "githubLocalActions.act.containerArchitecture": { + "markdownDescription": "The architecture which should be used to run containers (e.g.: `linux/amd64`). If not specified, the host default architecture will be used. This requires Docker server API Version 1.41+ (ignored on earlier Docker server platforms).", + "type": "string", + "default": "" + }, + "githubLocalActions.act.containerCapAdd": { + "markdownDescription": "Kernel capabilities to add to the workflow containers (e.g. `SYS_PTRACE`).", + "type": "array", + "default": [], "items": { "type": "string" } + }, + "githubLocalActions.act.containerCapDrop": { + "markdownDescription": "Kernel capabilities to remove from the workflow containers (e.g. `SYS_PTRACE`).", + "type": "array", + "default": [], + "items": { + "type": "string" + } + }, + "githubLocalActions.act.containerDaemonSocket": { + "markdownDescription": "URI to Docker Engine socket (e.g.: `unix://~/.docker/run/docker.sock` or `-` to disable bind mounting the socket).", + "type": "string", + "default": "" + }, + "githubLocalActions.act.containerOptions": { + "description": "Custom docker container options for the job container without an options property in the job definition.", + "type": "string", + "default": "" + }, + "githubLocalActions.act.defaultBranch": { + "description": "The name of the main branch.", + "type": "string", + "default": "" + }, + "githubLocalActions.act.detectEvent": { + "description": "Use first event type from workflow as event that triggered the workflow.", + "type": "boolean", + "default": false + }, + "githubLocalActions.act.directory": { + "markdownDescription": "The working directory used when running a `nektos/act` command.", + "type": "string", + "default": "." + }, + "githubLocalActions.act.githubInstance": { + "description": "The GitHub instance to use. Only use this when using GitHub Enterprise Server.", + "type": "string", + "default": "github.com" + }, + "githubLocalActions.act.insecureSecrets": { + "markdownDescription": "Show secrets while printing logs (**NOT RECOMMENDED!**).", + "type": "boolean", + "default": false + }, + "githubLocalActions.act.json": { + "description": "Output logs in json format.", + "type": "boolean", + "default": false + }, + "githubLocalActions.act.localRepository": { + "markdownDescription": "Replaces the specified repository and ref with a local folder (e.g. `https://github.com/test/test@v0=/home/act/test` or `test/test@v0=/home/act/test`, the latter matches any hosts or protocols).", + "type": "array", + "default": [], + "items": { + "type": "string" + } + }, + "githubLocalActions.act.logPrefixJobId": { + "description": "Output the job id within non-json logs instead of the entire name.", + "type": "boolean", + "default": false + }, + "githubLocalActions.act.network": { + "description": "Sets a docker network name.", + "type": "string", + "default": "host" + }, + "githubLocalActions.act.noCacheServer": { + "description": "Disable cache server.", + "type": "boolean", + "default": false + }, + "githubLocalActions.act.noRecurse": { + "markdownDescription": "Flag to disable running workflows from subdirectories of specified path in `--workflows`/`-W` flag.", + "type": "boolean", + "default": false + }, + "githubLocalActions.act.noSkipCheckout": { + "description": "Do not skip actions/checkout.", + "type": "boolean", + "default": false + }, + "githubLocalActions.act.privileged": { + "description": "Use privileged mode.", + "type": "boolean", + "default": false } } }, diff --git a/src/act.ts b/src/act.ts index dc84b68..b45e529 100644 --- a/src/act.ts +++ b/src/act.ts @@ -55,7 +55,11 @@ export enum Option { VariableFile = '--var-file', Input = '--input', InputFile = '--input-file', - PayloadFile = '--eventpath' + PayloadFile = '--eventpath', + + + ActionCachePath = '--action-cache-path', + ActionOfflineMode = '--action-offline-mode' } export interface CommandArgs { diff --git a/src/configurationManager.ts b/src/configurationManager.ts index bf047bc..889271f 100644 --- a/src/configurationManager.ts +++ b/src/configurationManager.ts @@ -1,3 +1,5 @@ +import * as os from "os"; +import * as path from "path"; import { ConfigurationTarget, workspace } from 'vscode'; export enum Platform { @@ -7,7 +9,8 @@ export enum Platform { } export enum Section { - dockerDesktopPath = 'dockerDesktopPath' + dockerDesktopPath = 'dockerDesktopPath', + actionCachePath = 'actionCachePath' } export namespace ConfigurationManager { @@ -30,6 +33,13 @@ export namespace ConfigurationManager { ConfigurationManager.set(Section.dockerDesktopPath, dockerDesktopPath); } + + let actionCachePath = ConfigurationManager.get(Section.actionCachePath); + if (!actionCachePath) { + actionCachePath = getCacheDirectory(['act']); + + ConfigurationManager.set(Section.actionCachePath, actionCachePath); + } } export function getSearchTerm(section: Section): string { @@ -43,4 +53,10 @@ export namespace ConfigurationManager { export async function set(section: Section, value: any): Promise { return await workspace.getConfiguration(ConfigurationManager.group).update(section, value, ConfigurationTarget.Global); } + + function getCacheDirectory(paths: string[]) { + const userHomeDir = os.homedir(); + const cacheHomeDir = process.env.XDG_CACHE_HOME || path.join(userHomeDir, '.cache'); + return path.join(cacheHomeDir, ...paths); + } } \ No newline at end of file