diff --git a/.changeset/metal-animals-notice.md b/.changeset/metal-animals-notice.md new file mode 100644 index 0000000000..c1a844ddb0 --- /dev/null +++ b/.changeset/metal-animals-notice.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-github': patch +--- + +Made "github:autolinks:create" action idempotent diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubAutolinks.ts b/plugins/scaffolder-backend-module-github/src/actions/githubAutolinks.ts index 85c7f5da6f..396d85708f 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubAutolinks.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubAutolinks.ts @@ -108,15 +108,20 @@ export function createGithubAutolinksAction(options: { }), ); - await client.rest.repos.createAutolink({ - owner, - repo, - key_prefix: keyPrefix, - url_template: urlTemplate, - is_alphanumeric: isAlphanumeric, - }); + await ctx.checkpoint({ + key: `create.auto.link.${owner}.${repo}`, + fn: async () => { + await client.rest.repos.createAutolink({ + owner, + repo, + key_prefix: keyPrefix, + url_template: urlTemplate, + is_alphanumeric: isAlphanumeric, + }); - ctx.logger.info(`Autolink reference created successfully`); + ctx.logger.info(`Autolink reference created successfully`); + }, + }); }, }); }