Repository navigation
fix(products): clarify Apple review submission and outcomes #1124
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync OpenAPI specs | ||
| on: | ||
| schedule: | ||
| # Every Monday at 09:00 UTC | ||
| - cron: "0 9 * * 1" | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: "Print diff without opening a PR" | ||
| type: boolean | ||
| default: false | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| jobs: | ||
| sync: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | ||
| - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | ||
| with: | ||
| python-version: "3.12" | ||
| - name: Install pyyaml | ||
| run: pip install pyyaml | ||
| - uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5 | ||
| with: | ||
| go-version-file: go.mod | ||
| cache: true | ||
| - name: Fetch latest specs | ||
| run: | | ||
| curl -fsSL "https://www.revenuecat.com/docs/redocusaurus/openapi-v1.yaml" \ | ||
| -o /tmp/v1-subscribers.yaml | ||
| curl -fsSL "https://www.revenuecat.com/docs/redocusaurus/openapi-v2.yaml" \ | ||
| -o /tmp/v2-developer.yaml | ||
| - name: Diff specs | ||
| id: diff | ||
| run: | | ||
| SUMMARY="" | ||
| CHANGED=false | ||
| run_diff() { | ||
| local label="$1" old="$2" new="$3" | ||
| shift 3 | ||
| # exit 0 = identical, 1 = changes found, anything else = real error. | ||
| # `|| status=$?` keeps the expected non-zero (changes found) from | ||
| # tripping the step's `set -e` before we can handle it. | ||
| local status=0 | ||
| section=$(python3 scripts/spec-diff.py "$old" "$new" --title "$label" "$@") || status=$? | ||
| if [ "$status" -eq 1 ]; then | ||
| SUMMARY="${SUMMARY}${section} | ||
| " | ||
| CHANGED=true | ||
| elif [ "$status" -ne 0 ]; then | ||
| echo "::error::spec-diff failed for $label (exit $status)" | ||
| exit "$status" | ||
| fi | ||
| } | ||
| run_diff "v1 Subscribers API" docs/specs/v1-subscribers.yaml /tmp/v1-subscribers.yaml | ||
| run_diff "v2 Developer API" docs/specs/v2-developer.yaml /tmp/v2-developer.yaml --coverage docs/specs/cli-coverage.yaml | ||
| if [ "$CHANGED" = "false" ]; then | ||
| SUMMARY="_No changes detected in any spec._" | ||
| fi | ||
| # Write multi-line output via $GITHUB_OUTPUT delimiter | ||
| { | ||
| echo "summary<<EOF_DIFF_SUMMARY" | ||
| printf '%s' "$SUMMARY" | ||
| echo "" | ||
| echo "EOF_DIFF_SUMMARY" | ||
| echo "changed=$CHANGED" | ||
| } >> "$GITHUB_OUTPUT" | ||
| - name: Update snapshots and regenerate API types | ||
| if: steps.diff.outputs.changed == 'true' | ||
| run: | | ||
| cp /tmp/v1-subscribers.yaml docs/specs/v1-subscribers.yaml | ||
| cp /tmp/v2-developer.yaml docs/specs/v2-developer.yaml | ||
| # Regenerate the Go types from the new v2 spec so the PR is complete | ||
| # and passes CI's codegen-drift check (was previously left stale). | ||
| make gen | ||
| - name: Open PR | ||
| if: steps.diff.outputs.changed == 'true' && inputs.dry_run != 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| SUMMARY: ${{ steps.diff.outputs.summary }} | ||
| run: | | ||
| BRANCH="spec-sync/$(date +%Y-%m-%d)" | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git checkout -b "$BRANCH" | ||
| git add docs/specs/ internal/api/types_gen.go | ||
| git commit -m "chore(specs): sync OpenAPI snapshots + regenerate types $(date +%Y-%m-%d)" | ||
| git push origin "$BRANCH" | ||
| # Write PR body to a file so ${SUMMARY} expands correctly | ||
| cat > /tmp/pr-body.md <<PREOF | ||
| ## OpenAPI spec changes | ||
| The weekly spec-sync job detected the following changes and regenerated \`internal/api/types_gen.go\` from the new v2 spec. Review them and update any CLI commands, API client code, or hand-written (excluded-schema) types that depend on the changed endpoints — a red build here means the generated types no longer match the code. | ||
| ${SUMMARY} | ||
| --- | ||
| _Generated by the [spec-sync workflow](.github/workflows/spec-sync.yml)._ | ||
| PREOF | ||
| gh pr create \ | ||
| --title "chore(specs): OpenAPI spec changes detected $(date +%Y-%m-%d)" \ | ||
| --body-file /tmp/pr-body.md \ | ||
| --label "spec-sync" \ | ||
| --head "$BRANCH" \ | ||
| --base main || true | ||
| - name: Print diff (dry run) | ||
| if: inputs.dry_run == 'true' | ||
| run: echo "${{ steps.diff.outputs.summary }}" | ||