forked from paritytech/metadata-portal
-
Notifications
You must be signed in to change notification settings - Fork 12
199 lines (176 loc) Β· 6.74 KB
/
update-and-sign.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: Check updates&sign
on:
workflow_dispatch:
schedule:
- cron: '0 */2 * * *'
env:
BRANCH_PREFIX: updated-codes
NOTIFY_MATRIX: false
NOTIFY_TELEGRAM: true
GITHUB_WORKFLOW_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: π Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: π§ Install rust dependencies
uses: ./.github/workflows/rust-install
- name: Try to checkout exising PR branch
id: checkout-pr
run: |
SIGN_ME_BRANCH=$(git branch -r --list "origin/$BRANCH_PREFIX-*" --sort=-refname | head -n 1)
if [ -z "$SIGN_ME_BRANCH" ]
then
switched="false"
else
git checkout --track $SIGN_ME_BRANCH
switched="true"
fi
echo "::set-output name=switched::$switched"
- name: β Build metadata-cli
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: β Update QRs from RPC nodes
id: update-nodes
run: |
cargo run --release -- -c=config.toml update --sign --signing-key ${{secrets.SIGNING_KEY}} --source node
exit_code=$?
if [ $exit_code -eq 12 ]
then
echo "::set-output name=chainsSkipped::true"
exit 0
fi
echo "::set-output name=chainsSkipped::false"
exit $exit_code
shell: bash {0}
- name: β Update QRs from GitHub releases
run: |
cargo run --release update --sign --signing-key ${{secrets.SIGNING_KEY}} --source github
- name: β Run collector
id: collect
run: |
cargo run --release collect
exit_code=$?
if [ $exit_code -eq 12 ]
then
echo "::set-output name=chainsSkipped::true"
exit 0
fi
echo "::set-output name=chainsSkipped::false"
exit $exit_code
shell: bash {0}
- name: π Commit changes if PR exists
if: ${{ steps.checkout-pr.outputs.switched == 'true' }}
uses: ./.github/workflows/commit-changes
with:
message: 'metadata update&sign'
- name: New PR branch
if: ${{ steps.checkout-pr.outputs.switched == 'false' }}
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.checkout-pr.outputs.switched == 'false' }}
id: cpr
uses: peter-evans/create-pull-request@f22a7da129c901513876a2380e2dae9f8e145330
with:
commit-message: add updated QR codes
branch: ${{ steps.new-branch.outputs.name }}
delete-branch: true
base: master
title: '[Automated] Review new metadata QRs'
body: |
Updated metadata QR codes
reviewers: "stepanLav,pgolovkin,tuul-wq,Asmadek"
draft: false
- name: Notify Matrix channel
uses: s3krit/matrix-message-action@v0.0.3
if: ${{ env.NOTIFY_MATRIX == 'true' && steps.cpr.outputs.pull-request-operation == 'created' }}
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
server: ${{ secrets.MATRIX_SERVER }}
message: "# New metadata is available and signed! π [GitHub PR#${{ steps.cpr.outputs.pull-request-number }}](${{ steps.cpr.outputs.pull-request-url }})"
- name: Notify Telegram channel
uses: appleboy/telegram-action@master
if: ${{ env.NOTIFY_TELEGRAM == 'true' && steps.cpr.outputs.pull-request-operation == 'created' }}
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
New metadata is available and signed! π
${{ steps.cpr.outputs.pull-request-url }}
- name: Send error to Matrix channel
uses: s3krit/matrix-message-action@v0.0.3
if: ${{ failure() && env.NOTIFY_MATRIX == 'true' }}
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
server: ${{ secrets.MATRIX_SERVER }}
message: "βοΈ Error updating metadata! β ${{ env.GITHUB_WORKFLOW_URL }}"
- name: Send error to Telegram channel
uses: appleboy/telegram-action@master
if: ${{ failure() && env.NOTIFY_TELEGRAM == 'true' }}
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
βοΈ Error updating metadata! β
${{ env.GITHUB_WORKFLOW_URL }}
- name: Send update warning to Matrix channel
uses: s3krit/matrix-message-action@v0.0.3
if: ${{ steps.update-nodes.outputs.chainsSkipped == 'true' && env.NOTIFY_MATRIX == 'true'}}
with:
room_id: ${{ secrets.MATRIX_ROOM_ID }}
access_token: ${{ secrets.MATRIX_ACCESS_TOKEN }}
server: ${{ secrets.MATRIX_SERVER }}
message: "β οΈ Some networks were not available! Please, check the log! β οΈ ${{ env.GITHUB_WORKFLOW_URL }}"
- name: Send update warning to Telegram channel
uses: appleboy/telegram-action@master
if: ${{ steps.update-nodes.outputs.chainsSkipped == 'true' && env.NOTIFY_TELEGRAM == 'true'}}
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: "β οΈ Some networks were not available! Please, check the log! β οΈ ${{ env.GITHUB_WORKFLOW_URL }}"
check-deployment:
runs-on: ubuntu-latest
steps:
- name: π Checkout
uses: actions/checkout@v3
- name: π§ Install rust dependencies
uses: ./.github/workflows/rust-install
- name: β Check existing deployment
id: check-deployment
run: |
cargo run --release -- check-deployment
exit_code=$?
if [ $exit_code -eq 12 ]
then
echo "::set-output name=redeploy::true"
exit 0
fi
echo "::set-output name=redeploy::false"
exit $exit_code
shell: bash {0}
- name: β Run collector
id: collect
if: ${{ steps.check-deployment.outputs.redeploy == 'true' }}
run: |
cargo run --release -- -c=config.toml collect
exit_code=$?
if [ $exit_code -eq 12 ]
then
exit 0
fi
exit $exit_code
shell: bash {0}
- if: ${{ steps.check-deployment.outputs.redeploy == 'true' }}
uses: ./.github/workflows/deploy
with:
token: ${{ secrets.GITHUB_TOKEN }}