Made "github:repo:create" action idempotent

Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
Bogdan Nechyporenko
2025-03-14 21:36:35 +01:00
parent 85df833fe3
commit 8f9c54c341
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:create" action idempotent
@@ -196,35 +196,41 @@ export function createGithubRepoCreateAction(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 = await ctx.checkpoint({
key: `create.repo.and.topics.${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,
);
return newRepo.clone_url;
},
});
ctx.output('remoteUrl', newRepo.clone_url);
ctx.output('remoteUrl', remoteUrl);
},
});
}