Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ci(platform): sync asyncapi.json from production every hour
An hourly workflow (and workflow_dispatch) compares
https://app.base44.com/api/asyncapi.json with the committed copy first, so
a run with nothing new stops before installing anything. When they differ
it regenerates the event types, builds the docs, runs the Platform SDK
tests and opens or updates one rolling PR on bot/platform-asyncapi-sync.
It closes that PR when main already matches production.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
amitbardos and claude committed Oct 13, 2026
commit 5bea8e5891547d61475e1bbb3edb195169fe4e18
103 changes: 103 additions & 0 deletions .github/workflows/sync-asyncapi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Sync Platform SDK AsyncAPI

# Refreshes packages/platform/asyncapi.json from production and regenerates the event
# types from it. Changes go to one rolling PR; closing it without merging only skips
# that run, since the next one proposes the same changes again.

on:
schedule:
- cron: "15 * * * *" # Every hour
workflow_dispatch:

permissions:
contents: write
pull-requests: write

concurrency:
group: sync-asyncapi
cancel-in-progress: false

env:
BRANCH: bot/platform-asyncapi-sync
ASYNCAPI_URL: https://app.base44.com/api/asyncapi.json

jobs:
sync:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
ref: main

- name: Wix gateway proxy (mandatory)
uses: ./.github/actions/wix-gateway-proxy

- name: Compare with production
id: production
run: |
curl -sf "$ASYNCAPI_URL" -o "$RUNNER_TEMP/asyncapi.json"
if python3 -c 'import json, sys; sys.exit(json.load(open(sys.argv[1])) != json.load(open(sys.argv[2])))' "$RUNNER_TEMP/asyncapi.json" packages/platform/asyncapi.json; then
echo "same=true" >> "$GITHUB_OUTPUT"
fi

- name: Use Node.js 20.x
if: steps.production.outputs.same != 'true'
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "20.x"
cache: "npm"

- name: Install dependencies
if: steps.production.outputs.same != 'true'
run: npm ci

- name: Sync asyncapi.json and regenerate the event types
if: steps.production.outputs.same != 'true'
run: |
npm run sync:asyncapi -w @base44/platform -- "$ASYNCAPI_URL"
npm run gen:events -w @base44/platform

- name: Check for changes
id: changes
run: |
if git diff --quiet -- packages/platform/asyncapi.json packages/platform/src/modules/builder.events.generated.ts; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "✅ asyncapi.json and the event types are up to date"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Close a stale sync PR
if: steps.changes.outputs.changed == 'false'
env:
GH_TOKEN: ${{ github.token }}
run: |
pr=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
if [ -n "$pr" ]; then gh pr close "$pr" --delete-branch --comment "main already matches production."; fi

- name: Build the docs and test the Platform SDK
if: steps.changes.outputs.changed == 'true'
run: |
npm run create-docs -w @base44/platform
npm test -w @base44/platform

- name: Update the sync PR
if: steps.changes.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -B "$BRANCH"
git add packages/platform/asyncapi.json packages/platform/src/modules/builder.events.generated.ts
git commit -m "chore(platform): sync asyncapi.json and the event types from production"
# Rebuilt from main every run, so the branch never drifts or conflicts.
git push --force origin "$BRANCH"
Comment thread
amitbardos marked this conversation as resolved.
Resolved

pr=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
body="Refreshes \`packages/platform/asyncapi.json\` from $ASYNCAPI_URL and regenerates \`builder.events.generated.ts\`. The docs build and the Platform SDK tests passed on this change. Checked against production every hour."
if [ -z "$pr" ]; then
gh pr create --head "$BRANCH" --base main --title "Sync Platform SDK events from production" --body "$body"
fi
2 changes: 1 addition & 1 deletion packages/platform/scripts/sync-asyncapi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Replaces asyncapi.json with the document a backend serves, production by default. Production
// publishes only beta and GA messages; for alpha ones point this at a dev backend, e.g. a local apper:
// npm run sync:asyncapi -- http://localhost:8000/api/asyncapi.json
// or set ASYNCAPI_URL. Then run `npm run gen:events`.
// or set ASYNCAPI_URL. Then run `npm run gen:events`. The hourly sync-asyncapi workflow does both.
import { writeFile } from "node:fs/promises";

const url = process.argv[2] ?? process.env.ASYNCAPI_URL ?? "https://app.base44.com/api/asyncapi.json";
Expand Down
Loading