Merge pull request #29230 from acierto/githubrepopush

Made "github:repo:push" action idempotent
This commit is contained in:
Ben Lambert
2025-03-17 08:36:05 +01:00
committed by GitHub
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);