diff --git a/src/act/act.ts b/src/act/act.ts index 6735bb2..9c20d77 100644 --- a/src/act/act.ts +++ b/src/act/act.ts @@ -17,6 +17,7 @@ export class Act { private secrets: ArgumentMap; private cwd: string; private workflowFile: string; + private vars: ArgumentMap; private env: ArgumentMap; private matrix: ArgumentMap; private platforms: ArgumentMap; @@ -28,6 +29,7 @@ export class Act { this.secrets = new ArgumentMap("-s"); this.cwd = cwd ?? process.cwd(); this.workflowFile = workflowFile ?? this.cwd; + this.vars = new ArgumentMap("--var"); this.env = new ArgumentMap("--env"); this.matrix = new ArgumentMap("--matrix", ":"); this.platforms = new ArgumentMap("--platform"); @@ -63,6 +65,21 @@ export class Act { return this; } + setVar(key: string, val: string) { + this.vars.map.set(key, val); + return this; + } + + deleteVar(key: string) { + this.vars.map.delete(key); + return this; + } + + clearVar() { + this.vars.map.clear(); + return this; + } + setEnv(key: string, val: string) { this.env.map.set(key, val); return this; @@ -339,6 +356,7 @@ export class Act { */ private async run(cmd: string[], opts?: RunOpts): Promise { const { cwd, actArguments, proxy } = await this.parseRunOpts(opts); + const vars = this.vars.toActArguments(); const env = this.env.toActArguments(); const secrets = this.secrets.toActArguments(); const input = this.input.toActArguments(); @@ -351,6 +369,7 @@ export class Act { opts?.logFile, ...cmd, ...secrets, + ...vars, ...env, ...input, ...event,