Skip to content

Commit

Permalink
feat: added support for passing vars (#68)
Browse files Browse the repository at this point in the history
Co-authored-by: Sam Peddamatham <[email protected]>
  • Loading branch information
im-sampm and im-sampm-demo authored Jan 9, 2024
1 parent a1b1567 commit 74b85dc
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/act/act.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class Act {
private secrets: ArgumentMap<string>;
private cwd: string;
private workflowFile: string;
private vars: ArgumentMap<string>;
private env: ArgumentMap<string>;
private matrix: ArgumentMap<string[]>;
private platforms: ArgumentMap<string>;
Expand All @@ -28,6 +29,7 @@ export class Act {
this.secrets = new ArgumentMap<string>("-s");
this.cwd = cwd ?? process.cwd();
this.workflowFile = workflowFile ?? this.cwd;
this.vars = new ArgumentMap<string>("--var");
this.env = new ArgumentMap<string>("--env");
this.matrix = new ArgumentMap<string[]>("--matrix", ":");
this.platforms = new ArgumentMap<string>("--platform");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -339,6 +356,7 @@ export class Act {
*/
private async run(cmd: string[], opts?: RunOpts): Promise<Step[]> {
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();
Expand All @@ -351,6 +369,7 @@ export class Act {
opts?.logFile,
...cmd,
...secrets,
...vars,
...env,
...input,
...event,
Expand Down

0 comments on commit 74b85dc

Please sign in to comment.