Skip to content

Check updates

Check updates #123

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@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
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@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2
- 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@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