Sync OpenAPI Spec #33
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 Spec | |
| on: | |
| schedule: | |
| - cron: "0 6 * * 1" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name != 'workflow_dispatch' || github.ref == 'refs/heads/main' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Checkout lance-namespace (upstream spec) | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: lance-format/lance-namespace | |
| ref: main | |
| path: lance-namespace | |
| - name: Copy lance-namespace REST API spec | |
| run: | | |
| set -euo pipefail | |
| test -s lance-namespace/docs/src/spec.yaml | |
| tmp="$(mktemp)" | |
| # Normalize to a trailing newline so git diff doesn't fail on "No newline at end of file". | |
| awk '1' lance-namespace/docs/src/spec.yaml > "$tmp" | |
| mv "$tmp" docs/api-reference/rest/openapi.yml | |
| - name: Create pull request | |
| id: cpr | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| token: ${{ secrets.DOCS_BOT_TOKEN }} | |
| title: "chore(docs): sync OpenAPI spec" | |
| commit-message: "chore(docs): sync OpenAPI spec" | |
| body: | | |
| Syncs `docs/api-reference/rest/openapi.yml` from `lance-format/lance-namespace` (`docs/src/rest.yaml`). | |
| branch: "chore/sync-openapi" | |
| delete-branch: true | |
| - name: Wait for checks and merge | |
| if: steps.cpr.outputs.pull-request-number != '' | |
| env: | |
| GH_TOKEN: ${{ secrets.DOCS_BOT_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| pr="${{ steps.cpr.outputs.pull-request-number }}" | |
| # Give the pull_request workflow a moment to register checks before watching. | |
| for i in $(seq 1 10); do | |
| if gh pr checks "$pr" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1; then break; fi | |
| sleep 15 | |
| done | |
| gh pr checks "$pr" -R "$GITHUB_REPOSITORY" --watch --fail-fast --interval 30 | |
| # --admin bypasses the "require status check" base-branch policy on the | |
| # immediate merge. Safe here: checks are already confirmed green above, and | |
| # the bot token (admin) only ever merges this one bot-generated sync PR. | |
| gh pr merge "$pr" -R "$GITHUB_REPOSITORY" --squash --delete-branch --admin |