Sync OpenRPC spec from nearcore #43
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 OpenRPC spec from nearcore | |
| on: | |
| schedule: | |
| - cron: "0 6 * * *" # Daily at 06:00 UTC | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.NEARPROTOCOL_CI_PR_ACCESS }} | |
| - name: Fetch latest openrpc.json from nearcore | |
| run: | | |
| LATEST_TAG=$(curl -sSfL \ | |
| -H "Accept: application/vnd.github+json" \ | |
| "https://api.github.com/repos/near/nearcore/releases/latest" \ | |
| | jq -r '.tag_name') | |
| URL="https://raw.githubusercontent.com/near/nearcore/${LATEST_TAG}/chain/jsonrpc/openapi/openrpc.json" | |
| if curl -sSf -o openrpc.json "$URL"; then | |
| echo "Using nearcore release: $LATEST_TAG" | |
| echo "NEARCORE_TAG=$LATEST_TAG" >> "$GITHUB_ENV" | |
| else | |
| echo "openrpc.json not found in release $LATEST_TAG, falling back to master" | |
| curl -sSfL \ | |
| "https://raw.githubusercontent.com/near/nearcore/master/chain/jsonrpc/openapi/openrpc.json" \ | |
| -o openrpc.json | |
| echo "NEARCORE_TAG=master" >> "$GITHUB_ENV" | |
| fi | |
| - name: Check for changes | |
| id: diff | |
| run: | | |
| if git diff --quiet openrpc.json; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Install Rust toolchain | |
| if: steps.diff.outputs.changed == 'true' | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Regenerate types | |
| if: steps.diff.outputs.changed == 'true' | |
| run: cargo build | |
| - name: Create Pull Request | |
| if: steps.diff.outputs.changed == 'true' | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.NEARPROTOCOL_CI_PR_ACCESS }} | |
| branch: chore/sync-openrpc-spec | |
| commit-message: "chore: sync openrpc.json and regenerate types" | |
| title: "chore: sync openrpc.json and regenerate types" | |
| body: | | |
| Auto-generated PR to update `openrpc.json` from | |
| [nearcore ${{ env.NEARCORE_TAG }}](https://github.com/near/nearcore/blob/${{ env.NEARCORE_TAG }}/chain/jsonrpc/openapi/openrpc.json) | |
| and regenerate `src/generated.rs`. | |
| Please review the diff and verify correctness. | |
| labels: automated |