Skip to content

docs: automate API reference regeneration (CI + RDE, nightly + manual)#80

Merged
zoltan-baba merged 3 commits into
mainfrom
docs/rde-api-autosync
Jun 30, 2026
Merged

docs: automate API reference regeneration (CI + RDE, nightly + manual)#80
zoltan-baba merged 3 commits into
mainfrom
docs/rde-api-autosync

Conversation

@gaborszakacs

@gaborszakacs gaborszakacs commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Keeps the generated API references in sync with their hosted OpenAPI specs, with no manual work. A scheduled + manually-triggerable GitHub Action detects when a spec changes, regenerates that reference, and opens a PR for review (it never commits to main).

Covers both the Bitrise CI API and the RDE API. Follow-up to #77 (merged), which generated the RDE reference natively.

How it's structured

One workflow file, matrixed over the two specs — each spec runs as its own job and opens its own PR (auto/ci-api-sync, auto/rde-api-sync). That keeps the two products independent (separate review/ownership, independent runs) while staying DRY; a third spec later is a one-line matrix entry.

What's included

  • api/bitrise-rde.json — committed RDE spec snapshot. docusaurus.config.ts now generates the RDE reference from the snapshot instead of the live URL (the CI reference already worked this way).
  • .github/workflows/sync-api-references.ymlschedule (nightly, 06:00 UTC) + workflow_dispatch. Per spec: detect change → gen-api-docs <spec> → open/update a PR via peter-evans/create-pull-request, scoped to that spec's files.
  • scripts/spec_sync.py — shared change detector for both specs:
    • ETag conditional GET (If-None-Match304) to skip unchanged downloads, plus
    • a SHA-256 content gate as the source of truth. The hosts emit different ETag kinds (RDE = content hash, CI = nginx mtime-size), so the hash is what decides "changed" — protecting against nginx ETag churn on redeploys and the no-ETag window. 30s fetch timeout.
  • scripts/sync_api_spec.py / scripts/sync_rde_spec.py — thin wrappers over the shared module.
  • scripts/*_sync_state.json — ETag + content-hash baselines (CI backfilled for a seamless migration).
  • .gitignore — ignore scripts/__pycache__/.

Setup note

For the bot's PRs to trigger the deploy preview + checks, add a PAT/App token as repo secret DOCS_SYNC_TOKEN. Without it the workflow falls back to GITHUB_TOKEN (PRs still open, but GITHUB_TOKEN-authored PRs don't trigger other workflows). Triggers activate once this is on main.

Verification

Both syncs run against their live hosts: CI → 304/unchanged (api/bitrise-ci.json untouched), RDE → 200 → SHA-matched unchanged (snapshot untouched; ETag captured). The changed, --update, and corrupted-hash paths were exercised; scripts compile; workflow YAML + matrix validate.

Pairs with bitrise-io/bitrise-codespaces#217, which makes the RDE host send the content ETag (now live).

🤖 Generated with Claude Code

Adds a scheduled + manual workflow that keeps the generated RDE API reference
in sync with the hosted OpenAPI spec, and unifies the spec-change detection
shared with the CI API spec.

- api/bitrise-rde.json: committed snapshot of the RDE spec; docusaurus.config.ts
  now generates from it instead of the live URL.
- .github/workflows/sync-rde-api.yml: nightly (06:00 UTC) + workflow_dispatch.
  On a detected change it regenerates the reference and opens a PR (never
  commits to main). Uses RDE_SYNC_TOKEN when present so the PR triggers checks;
  falls back to GITHUB_TOKEN.
- scripts/spec_sync.py: shared change detector — ETag conditional GET (304 when
  unchanged) plus a SHA-256 content gate as the source of truth, which handles
  the CI host's mtime-based ETag and the RDE host's content ETag alike. 30s
  fetch timeout.
- scripts/sync_api_spec.py, scripts/sync_rde_spec.py: thin wrappers over it.
- scripts/*_sync_state.json: ETag + content-hash baselines.
- .gitignore: ignore scripts/__pycache__/.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Generalize the nightly/manual sync workflow to handle the Bitrise CI API spec
as well as RDE. Each spec runs as its own matrix job — its own PR branch
(auto/ci-api-sync, auto/rde-api-sync), independent of the other — so the two
products stay separate for review and don't block each other on a flaky host.

Renames the workflow to sync-api-references.yml and the optional PAT secret to
DOCS_SYNC_TOKEN (it now covers all docs API syncs).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gaborszakacs gaborszakacs force-pushed the docs/rde-api-autosync branch from dbaf253 to d13b2de Compare June 29, 2026 17:40
@gaborszakacs gaborszakacs changed the title docs: automate RDE API reference regeneration (nightly + manual sync) docs: automate API reference regeneration (CI + RDE, nightly + manual) Jun 29, 2026
# Conflicts:
#	scripts/api_spec_sync_state.json
@github-actions

Copy link
Copy Markdown

@zoltan-baba zoltan-baba merged commit b2a98b0 into main Jun 30, 2026
1 check passed
@zoltan-baba zoltan-baba deleted the docs/rde-api-autosync branch June 30, 2026 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants