|
| 1 | + |
| 2 | +name: OpenRPC JSON Updater |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + paths: |
| 9 | + - 'docs/openrpc.json' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + clone-and-build-execution-apis: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout execution-apis repo |
| 18 | + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 |
| 19 | + with: |
| 20 | + ref: main |
| 21 | + repository: 'ethereum/execution-apis' |
| 22 | + path: 'execution-apis' |
| 23 | + |
| 24 | + - name: Use Node.js TLS 20 |
| 25 | + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 |
| 26 | + with: |
| 27 | + node-version: 20 |
| 28 | + |
| 29 | + - name: Install dependencies |
| 30 | + run: npm install |
| 31 | + working-directory: ./execution-apis |
| 32 | + |
| 33 | + - name: Build project |
| 34 | + run: npm run build |
| 35 | + working-directory: ./execution-apis |
| 36 | + |
| 37 | + - name: Upload openrpc.json as an artifact |
| 38 | + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 |
| 39 | + with: |
| 40 | + name: openrpc |
| 41 | + path: ./execution-apis/refs-openrpc.json |
| 42 | + |
| 43 | + update-openrpc: |
| 44 | + runs-on: ubuntu-latest |
| 45 | + needs: clone-and-build-execution-apis |
| 46 | + steps: |
| 47 | + - name: Checkout repository |
| 48 | + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 |
| 49 | + with: |
| 50 | + ref: 'main' |
| 51 | + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 52 | + |
| 53 | + - name: Download openrpc.json artifact |
| 54 | + uses: actions/download-artifact@v4 |
| 55 | + with: |
| 56 | + name: openrpc |
| 57 | + path: ./downloaded-artifacts/ |
| 58 | + |
| 59 | + - name: Copy generated openrpc.json to scripts directory |
| 60 | + run: | |
| 61 | + mkdir -p scripts/openrpc-json-updater |
| 62 | + cp ./downloaded-artifacts/refs-openrpc.json scripts/openrpc-json-updater/original-openrpc.json |
| 63 | +
|
| 64 | + - name: Setup Node.js |
| 65 | + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 |
| 66 | + with: |
| 67 | + node-version: '22' |
| 68 | + |
| 69 | + - name: Install dependencies |
| 70 | + working-directory: scripts/openrpc-json-updater |
| 71 | + run: npm install |
| 72 | + |
| 73 | + - name: Generate comparison report |
| 74 | + id: generate-report |
| 75 | + working-directory: scripts/openrpc-json-updater |
| 76 | + run: | |
| 77 | + REPORT_OUTPUT=$(node cli.js --original ./original-openrpc.json --modified ../../docs/openrpc.json) |
| 78 | + echo "REPORT_OUTPUT<<EOF" >> $GITHUB_ENV |
| 79 | + echo "$REPORT_OUTPUT" >> $GITHUB_ENV |
| 80 | + echo "EOF" >> $GITHUB_ENV |
| 81 | +
|
| 82 | + # This workflow automatically creates PRs when the OpenRPC JSON file differs from the upstream source. |
| 83 | + # PRs are only created when actual changes are detected (SKIP_PR=false), ensuring that |
| 84 | + # maintainers can review and approve schema updates before they're merged into the main branch. |
| 85 | + # This provides a safety mechanism for tracking OpenRPC specification changes over time. |
| 86 | + - name: Perform merge |
| 87 | + id: merge |
| 88 | + working-directory: scripts/openrpc-json-updater |
| 89 | + run: | |
| 90 | + MERGE_OUTPUT=$(node cli.js --merge --original ./original-openrpc.json --modified ../../docs/openrpc.json) |
| 91 | + MERGE_EXIT_CODE=$? |
| 92 | + echo "$MERGE_OUTPUT" |
| 93 | +
|
| 94 | + if [ $MERGE_EXIT_CODE -eq 0 ]; then |
| 95 | + if [[ "$MERGE_OUTPUT" =~ No\ differences\ found\ after\ merge ]]; then |
| 96 | + echo "No differences found. Skipping PR creation." |
| 97 | + echo "SKIP_PR=true" >> $GITHUB_ENV |
| 98 | + exit 0 |
| 99 | + elif [[ "$MERGE_OUTPUT" == *"Merge completed"* ]]; then |
| 100 | + echo "Successfully updated openrpc.json" |
| 101 | + echo "SKIP_PR=false" >> $GITHUB_ENV |
| 102 | + else |
| 103 | + echo "Unexpected output. Output was: $MERGE_OUTPUT" |
| 104 | + exit 1 |
| 105 | + fi |
| 106 | + else |
| 107 | + echo "Failed to update file. Output was: $MERGE_OUTPUT" |
| 108 | + exit 1 |
| 109 | + fi |
| 110 | +
|
| 111 | + - name: Generate unique branch name |
| 112 | + id: branch-name |
| 113 | + run: | |
| 114 | + TIMESTAMP=$(date +%Y%m%d%H%M%S) |
| 115 | + UNIQUE_BRANCH="update-openrpc-${TIMESTAMP}" |
| 116 | + echo "UNIQUE_BRANCH=${UNIQUE_BRANCH}" >> $GITHUB_ENV |
| 117 | + echo "Generated unique branch name: ${UNIQUE_BRANCH}" |
| 118 | +
|
| 119 | + - name: Create Pull Request |
| 120 | + if: env.SKIP_PR != 'true' |
| 121 | + uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 |
| 122 | + with: |
| 123 | + token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} |
| 124 | + commit-message: Update OpenRPC JSON |
| 125 | + title: 'Update OpenRPC JSON' |
| 126 | + body: | |
| 127 | + # OpenRPC JSON Update |
| 128 | +
|
| 129 | + This PR updates the OpenRPC JSON specification with the latest changes from Ethereum JSON-RPC specification. |
| 130 | +
|
| 131 | + ## Comparison Report |
| 132 | + ``` |
| 133 | + ${{ env.REPORT_OUTPUT }} |
| 134 | + ``` |
| 135 | + branch: ${{ env.UNIQUE_BRANCH }} |
| 136 | + base: 'main' |
| 137 | + add-paths: docs/openrpc.json |
| 138 | + delete-branch: true |
0 commit comments