diff --git a/src/act/act.constants.ts b/src/act/act.constants.ts index ffc524d..c585168 100644 --- a/src/act/act.constants.ts +++ b/src/act/act.constants.ts @@ -5,6 +5,7 @@ export const DEFAULT_JOB: Step = { name: "", status: -1, output: "", + outputs: {}, }; export const ACT_BINARY = process.env["ACT_BINARY"] ?? path.resolve(__dirname, "..", "..", "bin", "act"); \ No newline at end of file diff --git a/src/act/act.type.ts b/src/act/act.type.ts index 6fbc907..bacff4f 100644 --- a/src/act/act.type.ts +++ b/src/act/act.type.ts @@ -13,6 +13,7 @@ export type Step = { name: string; status: number; output: string; + outputs: Record; groups?: Group[]; }; diff --git a/src/output-parser/output-parser.ts b/src/output-parser/output-parser.ts index 98571c8..7eb3650 100644 --- a/src/output-parser/output-parser.ts +++ b/src/output-parser/output-parser.ts @@ -10,6 +10,8 @@ export class OutputParser { // keep track of output for the current step of a job private outputMatrix: Record; + private outputsMatrix: Record>; + // keep track of groups for the current step of a job private groupMatrix: Record; @@ -19,6 +21,7 @@ export class OutputParser { this.output = output; this.stepMatrix = {}; this.outputMatrix = {}; + this.outputsMatrix = {}; this.groupMatrix = {}; this.isPartOfGroup = {}; } @@ -37,6 +40,7 @@ export class OutputParser { this.parseStartGroup(line); this.parseEndGroup(line); this.parseStepOutput(line); + this.parseStepOutputs(line); } const result: Step[] = []; @@ -63,6 +67,7 @@ export class OutputParser { if (!this.stepMatrix[runMatcherResult[1]]) { this.stepMatrix[runMatcherResult[1]] = {}; this.outputMatrix[runMatcherResult[1]] = ""; + this.outputsMatrix[runMatcherResult[1]] = {}; this.groupMatrix[runMatcherResult[1]] = []; } @@ -94,6 +99,7 @@ export class OutputParser { ], status: 0, output: this.outputMatrix[successMatcherResult[1]].trim(), + outputs: this.outputsMatrix[successMatcherResult[1]], // only add groups attribute if there are any. don't add empty array ...(groups.length > 0 ? { groups } : {}), }; @@ -121,6 +127,7 @@ export class OutputParser { ], status: 1, output: this.outputMatrix[failureMatcherResult[1]].trim(), + outputs: this.outputsMatrix[failureMatcherResult[1]], }; this.resetOutputAndGroupMatrix(failureMatcherResult[1]); @@ -150,6 +157,21 @@ export class OutputParser { } } + /** + * Check if the line contains a set-output annotation. If it does then parse + * and store the output + * @param line + */ + private parseStepOutputs(line: string) { + const stepOutputsMatcher = /^\s*(\[.+\])\s*\u2699\s*::set-output::\s*(.*)=(.*)/; + const stepOutputsMatcherResult = stepOutputsMatcher.exec(line); + + // if the line is an output line + if (stepOutputsMatcherResult !== null) { + this.outputsMatrix[stepOutputsMatcherResult[1]][stepOutputsMatcherResult[2]] = stepOutputsMatcherResult[3]; + } + } + /** * Check if the line indicates the end of a group annotation. If it does then accordingly * update the bookkeeping variables