Renew vara #5963
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: Renew vara | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 */2 * * *' | |
env: | |
BRANCH_PREFIX: update-config-vara | |
CARGO_TERM_COLOR: always | |
TERM: xterm-256color | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🛎 Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Collation Genesis and SpecVersion | |
id: compare | |
run: | | |
# Check Genesis and SpecVersion | |
RenewedGenesis=$(curl -X POST https://rpc.vara-network.io -H 'Content-Type: application/json' -d '[ { "id": 1, "jsonrpc": "2.0", "method": "chain_getBlockHash", "params": [0]}]' | jq -r '.[].result'); | |
RenewedSpecVersion=$(curl -X POST https://rpc.vara-network.io -H 'Content-Type: application/json' -d '[ { "id": 1, "jsonrpc": "2.0", "method": "state_getRuntimeVersion", "params": []}]' | jq -r '.[].result.specVersion'); | |
# Read previous Genesis and SpecVersion from file | |
originalgenesis=$(sed '1!d' spec-vara.info) | |
originalspecVersion=$(sed '2!d' spec-vara.info) | |
NewValue="$RenewedGenesis\n$RenewedSpecVersion" | |
# Compare | |
if [ "$originalspecVersion" -ne "$RenewedSpecVersion" ] || [ "$originalgenesis" != "$RenewedGenesis" ] | |
then echo "Spec or Genesis change" && echo -e "$NewValue" > spec-vara.info && echo "::set-output name=metaChanged::true" | |
else echo "Spec and Genesis haven't changed" | |
fi | |
- name: Install dependencies | |
if: ${{ steps.compare.outputs.metaChanged == 'true' }} | |
working-directory: util | |
run: yarn install | |
- name: Build dependencies | |
if: ${{ steps.compare.outputs.metaChanged == 'true' }} | |
working-directory: util | |
run: yarn build | |
- name: Renew vara config | |
if: ${{ steps.compare.outputs.metaChanged == 'true' }} | |
working-directory: util | |
run: yarn update:vara | |
- name: New PR branch | |
if: ${{ steps.compare.outputs.metaChanged == 'true' }} | |
id: new-branch | |
run: | | |
NAME="$BRANCH_PREFIX-$(date '+%Y-%m-%d')" | |
echo "::set-output name=name::$NAME" | |
- name: Create Pull Request if not exist | |
if: ${{ steps.compare.outputs.metaChanged == 'true' }} | |
id: cpr | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
commit-message: add new vara config | |
branch: ${{ steps.new-branch.outputs.name }} | |
delete-branch: true | |
base: master | |
title: '[Automated] Renew vara config' | |
add-paths: | | |
spec-vara.info | |
config/* | |
body: | | |
New vara config | |
draft: false | |
reviewers: osipov-mit |