Made "publish:bitbucket" action idempotent
Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend-module-bitbucket': patch
|
||||
---
|
||||
|
||||
Made "publish:bitbucket" action idempotent
|
||||
@@ -368,15 +368,19 @@ export function createPublishBitbucketAction(options: {
|
||||
? createBitbucketCloudRepository
|
||||
: createBitbucketServerRepository;
|
||||
|
||||
const { remoteUrl, repoContentsUrl } = await createMethod({
|
||||
authorization,
|
||||
workspace: workspace || '',
|
||||
project,
|
||||
repo,
|
||||
repoVisibility,
|
||||
mainBranch: defaultBranch,
|
||||
description,
|
||||
apiBaseUrl,
|
||||
const { remoteUrl, repoContentsUrl } = await ctx.checkpoint({
|
||||
key: `create.repo.${host}.${repo}`,
|
||||
fn: async () =>
|
||||
createMethod({
|
||||
authorization,
|
||||
workspace: workspace || '',
|
||||
project,
|
||||
repo,
|
||||
repoVisibility,
|
||||
mainBranch: defaultBranch,
|
||||
description,
|
||||
apiBaseUrl,
|
||||
}),
|
||||
});
|
||||
|
||||
const gitAuthorInfo = {
|
||||
@@ -414,24 +418,33 @@ export function createPublishBitbucketAction(options: {
|
||||
};
|
||||
}
|
||||
|
||||
const commitResult = await initRepoAndPush({
|
||||
dir: getRepoSourceDirectory(ctx.workspacePath, ctx.input.sourcePath),
|
||||
remoteUrl,
|
||||
auth,
|
||||
defaultBranch,
|
||||
logger: ctx.logger,
|
||||
commitMessage: gitCommitMessage
|
||||
? gitCommitMessage
|
||||
: config.getOptionalString('scaffolder.defaultCommitMessage'),
|
||||
gitAuthorInfo,
|
||||
signingKey: signCommit ? signingKey : undefined,
|
||||
const commitHash = await ctx.checkpoint({
|
||||
key: `init.repo.and.push${host}.${repo}`,
|
||||
fn: async () => {
|
||||
const commitResult = await initRepoAndPush({
|
||||
dir: getRepoSourceDirectory(
|
||||
ctx.workspacePath,
|
||||
ctx.input.sourcePath,
|
||||
),
|
||||
remoteUrl,
|
||||
auth,
|
||||
defaultBranch,
|
||||
logger: ctx.logger,
|
||||
commitMessage: gitCommitMessage
|
||||
? gitCommitMessage
|
||||
: config.getOptionalString('scaffolder.defaultCommitMessage'),
|
||||
gitAuthorInfo,
|
||||
signingKey: signCommit ? signingKey : undefined,
|
||||
});
|
||||
return commitResult?.commitHash;
|
||||
},
|
||||
});
|
||||
|
||||
if (enableLFS && host !== 'bitbucket.org') {
|
||||
await performEnableLFS({ authorization, host, project, repo });
|
||||
}
|
||||
|
||||
ctx.output('commitHash', commitResult?.commitHash);
|
||||
ctx.output('commitHash', commitHash);
|
||||
ctx.output('remoteUrl', remoteUrl);
|
||||
ctx.output('repoContentsUrl', repoContentsUrl);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user