More missed commands #2
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 mainnet config | ||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 */2 * * *' | ||
env: | ||
BRANCH_PREFIX: update-config-mainnet | ||
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-mainnet.info) | ||
originalspecVersion=$(sed '2!d' spec-mainnet.info) | ||
NewValue="$RenewedGenesis\n$RenewedSpecVersion" | ||
# Compare | ||
if [ "$originalspecVersion" -ne "$RenewedSpecVersion" ] || [ "$originalgenesis" != "$RenewedGenesis" ] | ||
then echo "Spec or Genesis change" && echo -e "$NewValue" > spec-mainnet.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 mainnet config | ||
if: ${{ steps.compare.outputs.metaChanged == 'true' }} | ||
working-directory: util | ||
run: yarn update:vara-mainnet | ||
- 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: [Automated] Renew mainnet config | ||
branch: ${{ steps.new-branch.outputs.name }} | ||
delete-branch: true | ||
base: master | ||
title: '[Automated] Renew mainnet config' | ||
add-paths: | | ||
spec-mainnet.info | ||
config/* | ||
body: | | ||
New mainnet config | ||
draft: false | ||
reviewers: osipov-mit |