diff --git a/.changeset/common-bats-enjoy.md b/.changeset/common-bats-enjoy.md new file mode 100644 index 0000000000..1bf3b79c9e --- /dev/null +++ b/.changeset/common-bats-enjoy.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-github': patch +--- + +Made "github:pages:enable" action idempotent diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.ts b/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.ts index 7a676b52f2..7efee89a5d 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubPagesEnable.ts @@ -118,16 +118,21 @@ export function createGithubPagesEnableAction(options: { `Attempting to enable GitHub Pages for ${owner}/${repo} with "${buildType}" build type, on source branch "${sourceBranch}" and source path "${sourcePath}"`, ); - await client.request('POST /repos/{owner}/{repo}/pages', { - owner: owner, - repo: repo, - build_type: buildType, - source: { - branch: sourceBranch, - path: sourcePath, - }, - headers: { - 'X-GitHub-Api-Version': '2022-11-28', + await ctx.checkpoint({ + key: `enabled.github.pages.${owner}.${repo}`, + fn: async () => { + await client.request('POST /repos/{owner}/{repo}/pages', { + owner: owner, + repo: repo, + build_type: buildType, + source: { + branch: sourceBranch, + path: sourcePath, + }, + headers: { + 'X-GitHub-Api-Version': '2022-11-28', + }, + }); }, });