Skip to content

Commit b1e6c01

Browse files
fix: call setFailed when push fails with existing PR (review feedback)
Co-Authored-By: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com>
1 parent 256055b commit b1e6c01

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

dist/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39678,6 +39678,7 @@ async function pushWithFallback(branchName, owner, repo, octokit) {
3967839678
`- Merge or close this PR so the next run creates a fresh one, or\n` +
3967939679
`- Manually rebase this branch on \`${github.context.ref.replace("refs/heads/", "")}\` and re-run the workflow.`,
3968039680
});
39681+
core.setFailed(`Failed to push changes to '${branchName}' due to conflicts. A comment has been left on PR #${existingPRNumber}.`);
3968139682
}
3968239683
else {
3968339684
core.setFailed(`Failed to push changes to '${branchName}' and no existing PR was found to comment on.`);

src/sync.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,13 @@ describe("updateFromSourceSpec", () => {
327327
const commentCall = mockIssuesCreateComment.mock.calls[0][0];
328328
expect(commentCall.body).toContain("Sync failed");
329329
expect(commentCall.body).toContain("merge conflicts");
330+
331+
// Action should still fail (not silently succeed)
332+
expect(state.setFailedCalls).toEqual(
333+
expect.arrayContaining([
334+
expect.stringContaining("conflicts"),
335+
]),
336+
);
330337
});
331338

332339
it("should call setFailed when push fails and no existing PR to comment on", async () => {

src/sync.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,9 @@ async function pushWithFallback(
564564
`- Merge or close this PR so the next run creates a fresh one, or\n` +
565565
`- Manually rebase this branch on \`${github.context.ref.replace("refs/heads/", "")}\` and re-run the workflow.`,
566566
});
567+
core.setFailed(
568+
`Failed to push changes to '${branchName}' due to conflicts. A comment has been left on PR #${existingPRNumber}.`,
569+
);
567570
} else {
568571
core.setFailed(
569572
`Failed to push changes to '${branchName}' and no existing PR was found to comment on.`,

0 commit comments

Comments
 (0)