Skip to content

Commit

Permalink
adding successful PR numbers to the outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyAv46 committed Dec 15, 2023
1 parent e355f68 commit 8a76cca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/backport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export { experimentalDefaults };
enum Output {
wasSuccessful = "was_successful",
wasSuccessfulByTarget = "was_successful_by_target",
successfulPRs = "successful_prs",
}

export class Backport {
Expand Down Expand Up @@ -209,6 +210,7 @@ export class Backport {
);

const successByTarget = new Map<string, boolean>();
const successPRs = new Array<number>();
for (const target of target_branches) {
console.log(`Backporting to target branch '${target}...'`);

Expand Down Expand Up @@ -382,6 +384,7 @@ export class Backport {

const message = this.composeMessageForSuccess(new_pr.number, target);
successByTarget.set(target, true);
successPRs.push(new_pr.number);
await this.github.createComment({
owner,
repo,
Expand All @@ -404,7 +407,7 @@ export class Backport {
}
}

this.createOutput(successByTarget);
this.createOutput(successByTarget, successPRs);
} catch (error) {
if (error instanceof Error) {
console.error(error.message);
Expand Down Expand Up @@ -512,7 +515,7 @@ export class Backport {
- #${pr_number}`;
}

private createOutput(successByTarget: Map<string, boolean>) {
private createOutput(successByTarget: Map<string, boolean>, successPRs: Array<number>) {
const anyTargetFailed = Array.from(successByTarget.values()).includes(
false,
);
Expand All @@ -523,6 +526,9 @@ export class Backport {
"",
);
core.setOutput(Output.wasSuccessfulByTarget, byTargetOutput);

const successPRsOutput = successPRs.join("\n");
core.setOutput(Output.successfulPRs, successPRsOutput);
}
}

Expand Down

0 comments on commit 8a76cca

Please sign in to comment.