Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

ci: Post Deploy Sync runs one at a time

Sidwebworks986fb16461ea
diff --git a/.claude/rules/sst-deployment-infrastructure.md b/.claude/rules/sst-deployment-infrastructure.md
index 9dd64840a1..6b4f908680 100644
--- a/.claude/rules/sst-deployment-infrastructure.md
+++ b/.claude/rules/sst-deployment-infrastructure.md
@@ -136,7 +136,9 @@ registration handshake, not Carbon-specific. Two independent triggers exist:
has no `/api/inngest` route to sync. For a workspace with a `project_id`
(hosted Supabase) it then copies the ERP's `/templates/*.html` into the
project's Auth emails (`ci/src/auth-emails.ts`): hosted Auth cannot
- download templates the way self-hosted Auth does.
+ download templates the way self-hosted Auth does. One sync at a time
+ (job-level `concurrency: post-deploy-sync`): each ERP deploy starts a run
+ that syncs every workspace, and two concurrent PUTs to one ERP collide.
Both hit the same handler (`apps/erp/app/routes/api+/inngest.ts`, `serve()`
from `inngest/remix`) — the registration target URL is fixed by that route's
diff --git a/.github/workflows/post-deploy.yml b/.github/workflows/post-deploy.yml
index 5e81e54090..c7a293e2de 100644
--- a/.github/workflows/post-deploy.yml
+++ b/.github/workflows/post-deploy.yml
@@ -15,10 +15,6 @@ on:
permissions:
contents: read
-# No concurrency group: GitHub takes a run's slot before its job `if`, so
-# a skipped run (an MES or docs deploy) replaced the AWS deploy's waiting
-# one. Runs may overlap; both steps are idempotent.
-
jobs:
sync:
name: Post Deploy Sync
@@ -28,6 +24,14 @@ jobs:
github.event_name != 'deployment_status' ||
(github.event.deployment_status.state == 'success' &&
startsWith(github.event.deployment.environment, 'Production – carbon'))
+ # One sync at a time: every run syncs every workspace, and two at once
+ # collide (Inngest answers the second PUT with a 400). On the job, not
+ # the workflow, so a skipped run (an MES or docs deploy) never takes
+ # the slot. A newer run replaces a waiting one; it syncs everything
+ # the waiting one would have, later.
+ concurrency:
+ group: post-deploy-sync
+ cancel-in-progress: false
runs-on: ubuntu-latest
steps: