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