Check updates #2012
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: Check updates | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 */12 * * *' | |
| env: | |
| BRANCH_NAME: automated-update-metadata | |
| jobs: | |
| update-metadata: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Rust | |
| uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7 | |
| with: | |
| profile: minimal | |
| toolchain: stable | |
| override: true | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@3cf7f8cc28d1b4e7d01e3783be10a97d55d483c8 # v2.7.1 | |
| - name: Try to checkout existing PR branch | |
| id: checkout-pr | |
| run: | | |
| EXISTING_BRANCH=$(git branch -r --list "origin/$BRANCH_NAME" --sort=-refname | head -n 1) | |
| if [ -z "$EXISTING_BRANCH" ] | |
| then | |
| switched="false" | |
| else | |
| git checkout --track $EXISTING_BRANCH | |
| switched="true" | |
| fi | |
| echo "switched=$switched" >> $GITHUB_OUTPUT | |
| - name: Download metadata | |
| run: | | |
| cargo install subxt-cli | |
| subxt metadata --format bytes --url wss://rpc.polkadot.io:443 > essentials/assets/polkadot_metadata.scale | |
| - name: Commit changes if PR exists | |
| if: ${{ steps.checkout-pr.outputs.switched == 'true' }} | |
| run: | | |
| git config --global user.name 'GitHub Action' | |
| git config --global user.email 'action@github.com' | |
| git add . | |
| git commit -m "Update metadata" || true | |
| git push | |
| - name: Create Pull Request if not exist | |
| if: ${{ steps.checkout-pr.outputs.switched == 'false' }} | |
| uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0 | |
| with: | |
| commit-message: Add new metadata | |
| branch: ${{ env.BRANCH_NAME }} | |
| delete-branch: true | |
| base: master | |
| title: '[Automated] Update metadata' | |
| body: New metadata uploaded |