-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
284 lines (259 loc) · 9.68 KB
/
action.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
name: Roboanimal dispatch
inputs:
comment-id:
description: 'The comment-id of the slash command'
required: true
file:
description: 'The file to run (e.g. main, hydrate_ci_cache)'
required: true
default: 'main'
network:
description: 'The network (e.g. eth, bsc, matic, ftm)'
required: true
default: 'eth'
fn:
description: 'Brownie function to run'
required: true
send:
description: 'Set to true to sign the tx and send to gnosis'
required: false
default: 'false'
pull_request_number:
description: 'Set to the pull request number for this command dispatch'
required: true
delete-branch-after-send:
description: 'Set to true to delete the PR branch after running with send=true'
default: 'true'
pull_request_title:
required: true
pull_request_author:
required: false
pull_request_description:
default: 'Empty PR description 🤡'
runs:
using: "composite"
steps:
- name: Create URL to the run output
id: vars
run: echo ::set-output name=run-url::https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
shell: bash
- name: Cache compiler installations
uses: actions/cache@v2
with:
path: |
/home/runner/.solcx
/home/runner/.vvm
key: ${{ runner.os }}-woofy-compiler-cache-v1
- name: Setup node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Install ganache
run: npm install -g [email protected]
shell: bash
- name: Set up python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Restore pip cache
uses: actions/cache@v2
id: pip-cache
with:
path: |
/home/runner/.cache/pip/
key: ${{ runner.os }}-pip-v2-${{ hashFiles('**/requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-pip-v2-${{ hashFiles('**/requirements-dev.txt') }}
${{ runner.os }}-pip-v2-
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r requirements-dev.txt
shell: bash
- name: Lock on send=true to avoid nonce race condition
if: ${{ inputs.send == 'true' }}
uses: shogo82148/actions-mutex@v1
with:
key: send-${{ inputs.network }}
- name: cache brownie database
uses: actions/cache@v2
with:
path: |
/home/runner/.brownie
!/home/runner/.brownie/accounts
key: ${{ runner.os }}-woofy-brownie-cache-v1
restore-keys: |
${{ runner.os }}-woofy-brownie-cache-v1
${{ runner.os }}-woofy-brownie-cache-*
${{ runner.os }}-woofy-brownie-cache
- name: delete .brownie/accounts after cache download
run: |
rm -rf ~/.brownie/accounts
shell: bash
- name: Add network config
run: |
brownie networks list true
cp network-config.yaml ~/.brownie/
brownie networks list true
shell: bash
- name: Run Function
id: fn
env:
POLYGON_ALCHEMY_PROJECT_ID: ${{ secrets.POLYGON_ALCHEMY_PROJECT_ID }}
POLYGONSCAN_TOKEN: ${{ secrets.POLYGONSCAN_TOKEN }}
FTMSCAN_TOKEN: ${{ secrets.FTMSCAN_TOKEN }}
ETHERSCAN_TOKEN: ${{ secrets.ETHERSCAN_TOKEN }}
WEB3_INFURA_PROJECT_ID: ${{ secrets.WEB3_INFURA_PROJECT_ID }}
PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
GITHUB_ACTION_SEND: ${{ inputs.send }}
run: |
python3 $GITHUB_WORKSPACE/scripts/run_brownie.py brownie run ${{ inputs.file }} ${{ inputs.fn }} --network ${{ inputs.network }}-main-fork 1>output.txt 2>error.txt || EXIT_CODE=$?
echo "::set-output name=brownie-exit-code::$EXIT_CODE"
echo "::group:: Output"
cat output.txt
echo "::endgroup::"
echo "::group:: Error"
cat error.txt
echo "::endgroup::"
exit 0
shell: bash
- name: Check failure
id: failcheck
run: |
echo "::group:: Output"
cat output.txt
echo "::endgroup::"
echo "::group:: Error"
cat error.txt
echo "::endgroup::"
exit ${{ steps.fn.outputs.brownie-exit-code}}
shell: bash
- name: Read nonce
if: ${{ inputs.send == 'true' }}
id: nonce
uses: juliangruber/read-file-action@v1
with:
path: /home/runner/nonce.txt
trim: false
- name: Nonce fail check
if: ${{ failure() && steps.nonce.outcome == 'failure' }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ inputs.comment-id }}
body: |
> Did not find nonce.txt. Did you run with send=true without actually posting the transaction at the end of your function?
- name: Edit comment with error message
if: failure()
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ inputs.comment-id }}
body: |
> Failure: check output ${{ steps.vars.outputs.run-url }}
- name: Edit comment with dry run message
if: ${{ inputs.send == 'false' }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ inputs.comment-id }}
body: |
> Dry run success: ${{ steps.vars.outputs.run-url }}
> Rerun the command with send=true to publish the TX to the safe
- name: Set safe link
id: safe-link
run: |
if [ "${{inputs.network}}" = "ftm" ]
then
echo "::set-output name=safe-link::https://safe.fantom.network/#/safes/0x72a34AbafAB09b15E7191822A679f28E067C4a16/transactions"
elif [ "${{inputs.network}}" = "matic" ]
then
echo "::set-output name=safe-link::https://polygon.gnosis-safe.io/app/#/safes/0x6fb490DF3202a1b7e32765BCE47974133064C433/transactions"
else
echo "::set-output name=safe-link::https://gnosis-safe.io/app/#/safes/0x16388463d60FFE0661Cf7F1f31a7D658aC790ff7/transactions"
fi
shell: bash
- name: Edit comment with full run message
if: ${{ inputs.send == 'true' }}
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ inputs.comment-id }}
body: |
> TX with nonce ${{ steps.nonce.outputs.content }} successfully sent: ${{ steps.vars.outputs.run-url }}.
> Find your queued TX at ${{ steps.safe-link.outputs.safe-link }}
> Your PR has been labeled with tag ${{inputs.network}} ${{ steps.nonce.outputs.content }}, which you can find here: https://github.com/yearn/strategist-ms/labels?q=${{ steps.nonce.outputs.content }}
- name: Set PR url
id: pr-url
run: |
echo "::set-output name=pr-url::https://github.com/${{github.repository}}/pull/${{ inputs.pull_request_number }}/files"
shell: bash
- name: Create Telegram message
id: telegram-message
run: |
TELEGRAM_MESSAGE=$(cat << EOF
✍️ [${{ inputs.network}} #${{ steps.nonce.outputs.content }}](${{ steps.safe-link.outputs.safe-link }}) \`${{ inputs.pull_request_title }}\`
Sender: ${{ inputs.pull_request_author }}
Description: \`${{ inputs.pull_request_description }}\`
Review [the code](${{ steps.pr-url.outputs.pr-url }}), verify [the output](${{ steps.vars.outputs.run-url }}), and [sign here](${{ steps.safe-link.outputs.safe-link }})
EOF
)
echo "TELEGRAM_MESSAGE<<EOF" >> $GITHUB_ENV
echo "$TELEGRAM_MESSAGE" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
shell: bash
- name: New TX Telegram Alert - Robowoofy Alert Chat
if: ${{ inputs.send == 'true' }}
uses: appleboy/telegram-action@master
with:
to: '-563056561'
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
${{ env.TELEGRAM_MESSAGE }}
continue-on-error: true
- name: New TX Telegram Alert - MultiSig Chat
if: ${{ inputs.send == 'true' }}
uses: appleboy/telegram-action@master
with:
to: '-1001560526095'
token: ${{ secrets.TELEGRAM_TOKEN }}
format: markdown
message: |
${{ env.TELEGRAM_MESSAGE }}
continue-on-error: true
- uses: actions-ecosystem/action-add-labels@v1
if: ${{ inputs.send == 'true' }}
with:
number: ${{ inputs.pull_request_number }}
github_token: ${{ secrets.GITHUB_TOKEN }}
labels: |
${{ inputs.network }} #${{ steps.nonce.outputs.content }}
- uses: peter-evans/close-pull@v1
if: ${{ inputs.send == 'true' }}
with:
pull-request-number: ${{ inputs.pull_request_number }}
comment: Auto-closing pull request
- name: Delete PRs head branches
if: ${{ inputs.delete-branch-after-send == 'true' && inputs.send == 'true'}}
uses: dawidd6/action-delete-branch@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
numbers: ${{ inputs.pull_request_number }}
- name: Add reaction
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ env.GITHUB_REPOSITORY }}
comment-id: ${{ inputs.comment-id }}
reaction-type: hooray
- name: Telegram Alert On Infra Failure
if: ${{ failure() && steps.failcheck.outcome == 'success' }}
uses: appleboy/telegram-action@master
with:
to: '-1001590254795'
token: ${{ secrets.TELEGRAM_TOKEN }}
message: |
Grrrr grrrrr grrrrr ${{ steps.vars.outputs.run-url }} pipeline failed even though the brownie function succeeded!
continue-on-error: true
- name: delete .brownie/accounts before cache upload
run: |
rm -rf ~/.brownie/accounts
shell: bash