Made "publish:github" action idempotent

Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
Bogdan Nechyporenko
2025-03-18 20:31:03 +01:00
parent 403bb43d3d
commit 0be1a1eeac
2 changed files with 41 additions and 29 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend-module-github': patch
---
Made "publish:github" action idempotent
@@ -241,36 +241,43 @@ export function createPublishGithubAction(options: {
});
const client = new Octokit(octokitOptions);
const newRepo = await createGithubRepoWithCollaboratorsAndTopics(
client,
repo,
owner,
repoVisibility,
description,
homepage,
deleteBranchOnMerge,
allowMergeCommit,
allowSquashMerge,
squashMergeCommitTitle,
squashMergeCommitMessage,
allowRebaseMerge,
allowAutoMerge,
access,
collaborators,
hasProjects,
hasWiki,
hasIssues,
topics,
repoVariables,
secrets,
oidcCustomization,
customProperties,
subscribe,
ctx.logger,
);
const { remoteUrl, repoContentsUrl } = await ctx.checkpoint({
key: `create.github.repo.${owner}.${repo}`,
fn: async () => {
const newRepo = await createGithubRepoWithCollaboratorsAndTopics(
client,
repo,
owner,
repoVisibility,
description,
homepage,
deleteBranchOnMerge,
allowMergeCommit,
allowSquashMerge,
squashMergeCommitTitle,
squashMergeCommitMessage,
allowRebaseMerge,
allowAutoMerge,
access,
collaborators,
hasProjects,
hasWiki,
hasIssues,
topics,
repoVariables,
secrets,
oidcCustomization,
customProperties,
subscribe,
ctx.logger,
);
const remoteUrl = newRepo.clone_url;
const repoContentsUrl = `${newRepo.html_url}/blob/${defaultBranch}`;
return {
remoteUrl: newRepo.clone_url,
repoContentsUrl: `${newRepo.html_url}/blob/${defaultBranch}`,
};
},
});
const commitResult = await initRepoPushAndProtect(
remoteUrl,