Made "github:repo:push" action idempotent

Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
Bogdan Nechyporenko
2025-03-14 21:33:27 +01:00
parent 85df833fe3
commit 89948b2bfd
2 changed files with 39 additions and 28 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend-module-github': patch
---
Made "github:repo:push" action idempotent
@@ -165,34 +165,40 @@ export function createGithubRepoPushAction(options: {
const remoteUrl = targetRepo.data.clone_url;
const repoContentsUrl = `${targetRepo.data.html_url}/blob/${defaultBranch}`;
const { commitHash } = await initRepoPushAndProtect(
remoteUrl,
octokitOptions.auth,
ctx.workspacePath,
ctx.input.sourcePath,
defaultBranch,
protectDefaultBranch,
protectEnforceAdmins,
owner,
client,
repo,
requireCodeOwnerReviews,
bypassPullRequestAllowances,
requiredApprovingReviewCount,
restrictions,
requiredStatusCheckContexts,
requireBranchesToBeUpToDate,
requiredConversationResolution,
requireLastPushApproval,
config,
ctx.logger,
gitCommitMessage,
gitAuthorName,
gitAuthorEmail,
dismissStaleReviews,
requiredCommitSigning,
requiredLinearHistory,
);
const commitHash = await ctx.checkpoint({
key: `init.repo.publish.${owner}.${client}.${repo}`,
fn: async () => {
const { commitHash: hash } = await initRepoPushAndProtect(
remoteUrl,
octokitOptions.auth,
ctx.workspacePath,
ctx.input.sourcePath,
defaultBranch,
protectDefaultBranch,
protectEnforceAdmins,
owner,
client,
repo,
requireCodeOwnerReviews,
bypassPullRequestAllowances,
requiredApprovingReviewCount,
restrictions,
requiredStatusCheckContexts,
requireBranchesToBeUpToDate,
requiredConversationResolution,
requireLastPushApproval,
config,
ctx.logger,
gitCommitMessage,
gitAuthorName,
gitAuthorEmail,
dismissStaleReviews,
requiredCommitSigning,
requiredLinearHistory,
);
return hash;
},
});
ctx.output('remoteUrl', remoteUrl);
ctx.output('repoContentsUrl', repoContentsUrl);