Check updates #92
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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 | |
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@578b235f6e5f613f7727f1c17bd3305b4d4d4e1f # v2.6.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://rococo-rpc.polkadot.io:443 > essentials/assets/rococo_metadata.scale | |
subxt metadata --format bytes --url wss://kusama-rpc.polkadot.io:443 > essentials/assets/kusama_metadata.scale | |
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@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2 | |
with: | |
commit-message: Add new metadata | |
branch: ${{ env.BRANCH_NAME }} | |
delete-branch: true | |
base: master | |
title: '[Automated] Update metadata' | |
body: New metadata uploaded |