From fc752094e5dacd2113cd3bd1c19bea0fef7b34e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Birm=C3=A9?= Date: Wed, 30 Sep 2026 09:31:17 +0200 Subject: [PATCH 1/3] ci: sync fork and remake in OSC dev on push to main Co-Authored-By: Claude --- .github/workflows/sync-fork-dev.yml | 79 +++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/sync-fork-dev.yml diff --git a/.github/workflows/sync-fork-dev.yml b/.github/workflows/sync-fork-dev.yml new file mode 100644 index 0000000..2076d24 --- /dev/null +++ b/.github/workflows/sync-fork-dev.yml @@ -0,0 +1,79 @@ +name: Sync fork in dev + +on: + push: + branches: + - main + workflow_dispatch: + +concurrency: + group: sync-fork-dev + cancel-in-progress: false + +jobs: + sync-fork-dev: + name: Sync fork and remake in dev + runs-on: ubuntu-latest + timeout-minutes: 60 + env: + MAKER_URL: https://maker.svc.dev.osaas.io + MAKER_API_KEY: ${{ secrets.OSC_DEV_MAKER_API_KEY }} + REPO_URL: https://github.com/${{ github.repository }} + steps: + - name: Trigger sync-fork + id: sync + run: | + set -euo pipefail + if [ -z "$MAKER_API_KEY" ]; then + echo "::error::Secret OSC_DEV_MAKER_API_KEY is not set" + exit 1 + fi + JOB_ID=$(curl -sf -X POST "$MAKER_URL/sync-fork" \ + -H "Authorization: Bearer $MAKER_API_KEY" \ + -H "Content-Type: application/json" \ + -d "{\"repositoryUrl\":\"$REPO_URL\"}" | jq -r '.jobId') + echo "Sync-fork job: $JOB_ID" + echo "job_id=$JOB_ID" >> "$GITHUB_OUTPUT" + + - name: Wait for sync-fork job + env: + JOB_ID: ${{ steps.sync.outputs.job_id }} + run: | + set -euo pipefail + for i in $(seq 1 60); do + RESP=$(curl -sf "$MAKER_URL/sync-fork/$JOB_ID" \ + -H "Authorization: Bearer $MAKER_API_KEY" || echo '{}') + STATUS=$(echo "$RESP" | jq -r '.status // "unknown"') + echo "sync-fork $JOB_ID status: $STATUS" + case "$STATUS" in + succeeded) exit 0 ;; + failed) + echo "::error::Sync-fork failed: $(echo "$RESP" | jq -r '.reason // "unknown"') $(echo "$RESP" | jq -r '.message // ""')" + exit 1 + ;; + esac + sleep 20 + done + echo "::error::Timed out waiting for sync-fork job" + exit 1 + + - name: Wait for remake to complete + run: | + set -euo pipefail + for i in $(seq 1 120); do + PHASE=$(curl -sf -G "$MAKER_URL/maker" \ + --data-urlencode "repositoryUrl=$REPO_URL" \ + -H "Authorization: Bearer $MAKER_API_KEY" \ + | jq -r '.[0].order.status.phase // "NOT_FOUND"' || echo "UNKNOWN") + echo "order phase: $PHASE" + case "$PHASE" in + DONE) exit 0 ;; + FAILED|ERROR) + echo "::error::Remake ended in phase $PHASE" + exit 1 + ;; + esac + sleep 20 + done + echo "::error::Timed out waiting for remake" + exit 1 From 8daf7927a25e972bd3b228db36e13d6bbf4c75f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Birm=C3=A9?= Date: Wed, 30 Sep 2026 09:34:02 +0200 Subject: [PATCH 2/3] ci: fail if order not remade or missing, guard jobId Co-Authored-By: Claude --- .github/workflows/sync-fork-dev.yml | 31 ++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/sync-fork-dev.yml b/.github/workflows/sync-fork-dev.yml index 2076d24..3af6c0a 100644 --- a/.github/workflows/sync-fork-dev.yml +++ b/.github/workflows/sync-fork-dev.yml @@ -28,10 +28,20 @@ jobs: echo "::error::Secret OSC_DEV_MAKER_API_KEY is not set" exit 1 fi + PREV_ORDER_ID=$(curl -sf -G "$MAKER_URL/maker" \ + --data-urlencode "repositoryUrl=$REPO_URL" \ + -H "Authorization: Bearer $MAKER_API_KEY" \ + | jq -r '.[0].order.orderId // "none"') + echo "Order before sync: $PREV_ORDER_ID" + echo "prev_order_id=$PREV_ORDER_ID" >> "$GITHUB_OUTPUT" JOB_ID=$(curl -sf -X POST "$MAKER_URL/sync-fork" \ -H "Authorization: Bearer $MAKER_API_KEY" \ -H "Content-Type: application/json" \ - -d "{\"repositoryUrl\":\"$REPO_URL\"}" | jq -r '.jobId') + -d "{\"repositoryUrl\":\"$REPO_URL\"}" | jq -r '.jobId // empty') + if [ -z "$JOB_ID" ]; then + echo "::error::No jobId returned from POST /sync-fork" + exit 1 + fi echo "Sync-fork job: $JOB_ID" echo "job_id=$JOB_ID" >> "$GITHUB_OUTPUT" @@ -58,14 +68,25 @@ jobs: exit 1 - name: Wait for remake to complete + env: + PREV_ORDER_ID: ${{ steps.sync.outputs.prev_order_id }} run: | set -euo pipefail for i in $(seq 1 120); do - PHASE=$(curl -sf -G "$MAKER_URL/maker" \ + ORDER=$(curl -sf -G "$MAKER_URL/maker" \ --data-urlencode "repositoryUrl=$REPO_URL" \ - -H "Authorization: Bearer $MAKER_API_KEY" \ - | jq -r '.[0].order.status.phase // "NOT_FOUND"' || echo "UNKNOWN") - echo "order phase: $PHASE" + -H "Authorization: Bearer $MAKER_API_KEY" || echo '[]') + ORDER_ID=$(echo "$ORDER" | jq -r '.[0].order.orderId // "none"') + PHASE=$(echo "$ORDER" | jq -r '.[0].order.status.phase // "NOT_FOUND"') + echo "order $ORDER_ID phase: $PHASE" + if [ "$ORDER_ID" = "none" ]; then + echo "::error::No order found in dev for $REPO_URL" + exit 1 + fi + if [ "$ORDER_ID" = "$PREV_ORDER_ID" ]; then + echo "::error::Order was not remade (same order id $ORDER_ID); a build may have been in progress" + exit 1 + fi case "$PHASE" in DONE) exit 0 ;; FAILED|ERROR) From 85041201621a0cb351707f7fe2aadba1317c8068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Birm=C3=A9?= Date: Wed, 30 Sep 2026 09:35:45 +0200 Subject: [PATCH 3/3] ci: trigger on merged PRs to main instead of push Co-Authored-By: Claude --- .github/workflows/sync-fork-dev.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sync-fork-dev.yml b/.github/workflows/sync-fork-dev.yml index 3af6c0a..207c4b9 100644 --- a/.github/workflows/sync-fork-dev.yml +++ b/.github/workflows/sync-fork-dev.yml @@ -1,7 +1,8 @@ name: Sync fork in dev on: - push: + pull_request_target: + types: [closed] branches: - main workflow_dispatch: @@ -13,6 +14,7 @@ concurrency: jobs: sync-fork-dev: name: Sync fork and remake in dev + if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true runs-on: ubuntu-latest timeout-minutes: 60 env: