From dda9728473e070258c8e62b915d77b1424f92d16 Mon Sep 17 00:00:00 2001 From: Ragnor Comerford Date: Fri, 17 Apr 2026 19:09:36 +0200 Subject: [PATCH] Add openapi.json auto-sync workflow --- .github/workflows/openapi-sync.yml | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/openapi-sync.yml diff --git a/.github/workflows/openapi-sync.yml b/.github/workflows/openapi-sync.yml new file mode 100644 index 0000000..52bf882 --- /dev/null +++ b/.github/workflows/openapi-sync.yml @@ -0,0 +1,60 @@ +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