forked from paritytech/metadata-portal
-
Notifications
You must be signed in to change notification settings - Fork 13
130 lines (110 loc) · 4 KB
/
update.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
name: Check updates
on:
workflow_dispatch:
schedule:
- cron: '0 */2 * * *'
env:
BRANCH_PREFIX: sign-me
NOTIFY_MATRIX: true
permissions:
pull-requests: write
contents: write
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: 🛎 Checkout
uses: actions/checkout@v4
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 "switched=$switched" >> $GITHUB_OUTPUT
- name: ⚙ Build metadata-cli
run: cargo build --release
- name: ⚙ Update QRs from RPC nodes
run: cargo run --release -- update --source node
- name: ⚙ Update QRs from GitHub releases
run: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} cargo run --release -- update --source github
- name: 📌 Commit changes if PR exists
if: ${{ steps.checkout-pr.outputs.switched == 'true' }}
uses: ./.github/workflows/commit-changes
with:
message: 'metadata update'
- name: New PR branch
if: ${{ steps.checkout-pr.outputs.switched == 'false' }}
id: new-branch
run: |
NAME="$BRANCH_PREFIX-$(date '+%Y-%m-%d')"
echo "name=$NAME" >> $GITHUB_OUTPUT
- name: 🔑 Generate token
uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.NOVASAMA_APP_ID }}
private_key: ${{ secrets.NOVASAMA_APP_PRIVATE_KEY }}
- name: Create Pull Request if not exist
if: ${{ steps.checkout-pr.outputs.switched == 'false' }}
id: cpr
uses: peter-evans/create-pull-request@v4
with:
token: ${{ steps.generate-token.outputs.token }}
commit-message: add unsigned QR codes
branch: ${{ steps.new-branch.outputs.name }}
delete-branch: true
base: master
title: '[Automated] Sign new metadata QRs'
body: |
Checkout this branch locally and run:
- [ ] `make signer` to sign files
- [ ] `make collector` to gather information about current chain versions
- [ ] `make cleaner` to remove obsolete QRs
reviewers: "stepanLav,pgolovkin,tuul-wq,Asmadek"
draft: true
- 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! 📑
[GitHub PR#${{ steps.cpr.outputs.pull-request-number }}](${{ steps.cpr.outputs.pull-request-url }})"
check-deployment:
runs-on: ubuntu-latest
steps:
- name: 🛎 Checkout
uses: actions/checkout@v4
- 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 "redeploy=true" >> $GITHUB_OUTPUT
exit 0
fi
echo "redeploy=false" >> $GITHUB_OUTPUT
exit $exit_code
shell: bash {0}
- name: ⚙ Run collector
if: ${{ steps.check-deployment.outputs.redeploy == 'true' }}
run: make collector
- if: ${{ steps.check-deployment.outputs.redeploy == 'true' }}
uses: ./.github/workflows/deploy
with:
token: ${{ secrets.GITHUB_TOKEN }}