name: Sync OpenAPI on: pull_request: paths: - "crates/omnigraph-server/src/**" - "crates/omnigraph-server/Cargo.toml" - "crates/omnigraph-server/tests/openapi.rs" concurrency: group: openapi-sync-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: write jobs: sync: name: Regenerate openapi.json # Auto-commit only on same-repo PRs; forks cannot be pushed to. if: github.event.pull_request.head.repo.full_name == github.repository runs-on: ubuntu-latest timeout-minutes: 30 steps: - name: Checkout PR branch uses: actions/checkout@v5.0.1 with: ref: ${{ github.head_ref }} token: ${{ secrets.GITHUB_TOKEN }} - name: Install system dependencies run: | sudo apt-get update sudo apt-get install -y protobuf-compiler libprotobuf-dev - name: Install Rust stable uses: dtolnay/rust-toolchain@stable - name: Cache Rust build data uses: Swatinem/rust-cache@v2 with: workspaces: | . -> target - name: Regenerate openapi.json run: | OMNIGRAPH_UPDATE_OPENAPI=1 \ cargo test --locked -p omnigraph-server --test openapi openapi_spec_is_up_to_date - name: Commit if changed run: | if git diff --quiet -- openapi.json; then echo "openapi.json is already in sync." exit 0 fi git config user.name "github-actions[bot]" git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git add openapi.json git commit -m "chore: regenerate openapi.json" git push