Check updates #882
This file contains 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
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 '[email protected]' | |
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@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.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 |