diff --git a/.changeset/twenty-walls-join.md b/.changeset/twenty-walls-join.md new file mode 100644 index 0000000000..2282e28775 --- /dev/null +++ b/.changeset/twenty-walls-join.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-github': patch +--- + +Made "github:actions:dispatch" action idempotent diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubActionsDispatch.ts b/plugins/scaffolder-backend-module-github/src/actions/githubActionsDispatch.ts index 8e185a9567..4faa53e6b8 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubActionsDispatch.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubActionsDispatch.ts @@ -115,15 +115,20 @@ export function createGithubActionsDispatchAction(options: { }), ); - await client.rest.actions.createWorkflowDispatch({ - owner, - repo, - workflow_id: workflowId, - ref: branchOrTagName, - inputs: workflowInputs, - }); + await ctx.checkpoint({ + key: `create.workflow.dispatch.${owner}.${repo}.${workflowId}`, + fn: async () => { + await client.rest.actions.createWorkflowDispatch({ + owner, + repo, + workflow_id: workflowId, + ref: branchOrTagName, + inputs: workflowInputs, + }); - ctx.logger.info(`Workflow ${workflowId} dispatched successfully`); + ctx.logger.info(`Workflow ${workflowId} dispatched successfully`); + }, + }); }, }); }