Update Polkadot API #114
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: Update Polkadot API | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| check-updates: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| has_updates: ${{ steps.check-version.outputs.has_updates }} | |
| new_version: ${{ steps.check-version.outputs.new_version }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Get current Polkadot API version | |
| id: current-version | |
| run: | | |
| CURRENT_VERSION=$(npm list polkadot-api --json | jq -r '.dependencies."polkadot-api".version') | |
| echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| - name: Check latest Polkadot API version | |
| id: check-version | |
| run: | | |
| LATEST_VERSION=$(npm view polkadot-api version) | |
| echo "Latest version: $LATEST_VERSION" | |
| echo "Current version: ${{ steps.current-version.outputs.current_version }}" | |
| if [ "$LATEST_VERSION" != "${{ steps.current-version.outputs.current_version }}" ]; then | |
| echo "has_updates=true" >> $GITHUB_OUTPUT | |
| echo "new_version=$LATEST_VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_updates=false" >> $GITHUB_OUTPUT | |
| fi | |
| update-papi: | |
| needs: check-updates | |
| if: needs.check-updates.outputs.has_updates == 'true' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Update Polkadot API | |
| run: | | |
| npm install polkadot-api@${{ needs.check-updates.outputs.new_version }} | |
| npx papi | |
| - name: Run tests | |
| run: npm test | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "Update Polkadot API to v${{ needs.check-updates.outputs.new_version }}" | |
| title: "Update Polkadot API to v${{ needs.check-updates.outputs.new_version }}" | |
| body: | | |
| This PR updates Polkadot API to v${{ needs.check-updates.outputs.new_version }}. | |
| - Automatically generated by GitHub Actions | |
| - The descriptors have been regenerated using `papi` | |
| Please verify the changes and merge if all tests pass. | |
| branch: "update-papi-v${{ needs.check-updates.outputs.new_version }}" | |
| base: main | |
| labels: dependencies,automated |