mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-09 01:35:18 +02:00
Add openapi.json auto-sync workflow
This commit is contained in:
parent
e0d48ad825
commit
dda9728473
1 changed files with 60 additions and 0 deletions
60
.github/workflows/openapi-sync.yml
vendored
Normal file
60
.github/workflows/openapi-sync.yml
vendored
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue