Made "github:webhook" action idempotent

Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
Bogdan Nechyporenko
2025-03-14 21:30:29 +01:00
parent 85df833fe3
commit 8182a599fa
2 changed files with 22 additions and 10 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-backend-module-github': patch
---
Made "github:webhook" action idempotent
@@ -168,18 +168,25 @@ export function createGithubWebhookAction(options: {
try {
const insecure_ssl = insecureSsl ? '1' : '0';
await client.rest.repos.createWebhook({
owner,
repo,
config: {
url: webhookUrl,
content_type: contentType,
secret: webhookSecret,
insecure_ssl,
await ctx.checkpoint({
key: `create.webhhook.${owner}.${repo}.${webhookUrl}`,
fn: async () => {
await client.rest.repos.createWebhook({
owner,
repo,
config: {
url: webhookUrl,
content_type: contentType,
secret: webhookSecret,
insecure_ssl,
},
events,
active,
});
},
events,
active,
});
ctx.logger.info(`Webhook '${webhookUrl}' created successfully`);
} catch (e) {
assertError(e);