-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (67 loc) · 2.72 KB
/
renew-vara.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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