-
Notifications
You must be signed in to change notification settings - Fork 133
251 lines (226 loc) · 8.35 KB
/
deploy.devnet.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
---
name: DevNet Workflow
on: # yamllint disable-line rule:truthy
workflow_dispatch:
push:
branches:
- develop
permissions:
id-token: write
contents: read
security-events: write
jobs:
snyk:
name: Snyk and Publish
uses: ./.github/workflows/security.yml
secrets:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
SNYK_ORG: ${{ secrets.SNYK_ORG }}
build:
name: Build
uses: ./.github/workflows/build.yml
test:
name: Test
uses: ./.github/workflows/test.yml
needs: build
container_image_build:
name: Build/Push Container Image
runs-on: ubuntu-latest
environment: devnet
needs: build
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Download Polygon Edge Artifact
uses: actions/download-artifact@v3
with:
name: exzocoin
- run: tar -xvzf exzocoin.tar.gz
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: library/exzocoin
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $REGISTRY/$REPOSITORY:devnet -t $REGISTRY/$REPOSITORY:$IMAGE_TAG -f Dockerfile.release .
docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG
docker push $REGISTRY/$REPOSITORY:devnet
deploy_devnet:
name: Deploy DevNet
needs: build
concurrency: deploy_devnet
environment:
name: devnet
url: https://rpc.us-east-1.testing.psdk.io/
runs-on: ubuntu-latest
steps:
- name: Download Polygon Edge Artifact
uses: actions/download-artifact@v3
with:
name: exzocoin
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Notify Slack
uses: slackapi/[email protected]
if: false
continue-on-error: true
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEPLOYMENT_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Devnet Deployment - Started"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Devnet Deployment Status: ${{ job.status }}\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Job Status>"
}
}
]
}
- name: Publish Binary package to S3
run: |
aws s3 cp ./exzocoin.tar.gz s3://${{ secrets.POLYGON_EDGE_ARTIFACT_BUCKET }} --metadata "{\"commit_sha\":\"${GITHUB_SHA}\"}"
- name: Deploy DevNet
continue-on-error: true
env:
VALIDATOR_ASGS: ${{ secrets.VALIDATOR_ASGS }}
run: |
# Parallel deploy all nodes, relying on ALB Health Checks
echo "Deploying new Devnet"
echo "--------------------"
# Should finish relatively fast. Can add a check to guard against pre-mature cycle
echo "Cleaning up the data directories and stopping exzocoin Devnet service..."
aws ssm send-command --document-name exzocoin-validators-maintenance-clean-data --targets Key=tag:aws:autoscaling:groupName,Values=$VALIDATOR_ASGS >> /dev/null
for vasg in ${VALIDATOR_ASGS//,/ }
do
instance_id=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $vasg --query 'AutoScalingGroups[0].Instances[0].InstanceId' --output text)
echo "Draining $instance_id in $vasg"
irid=$(aws autoscaling start-instance-refresh --auto-scaling-group-name $vasg --query InstanceRefreshId --output text)
done
echo "Waiting for instance to clear health check..."
pending=true
until [ $pending != true ]
do
pending=false
sleep 10
for vasg in ${VALIDATOR_ASGS//,/ }
do
refresh_status=$(aws autoscaling describe-instance-refreshes --auto-scaling-group-name $vasg --query 'InstanceRefreshes[0].Status' --output text)
echo "ASG: $vasg"
echo "Status: $refresh_status"
if [ "$refresh_status" == "Successful" ]
then
VALIDATOR_ASGS=${VALIDATOR_ASGS//$vasg/}
instance_id=$(aws autoscaling describe-auto-scaling-groups --auto-scaling-group-names $vasg --query 'AutoScalingGroups[0].Instances[0].InstanceId' --output text)
echo "-------------------------------------------------"
echo "New validator: $instance_id successfully deployed"
echo "-------------------------------------------------"
fi
pending=true
done
echo ""
done
echo "Devnet Deployment Complete"
- name: Notify Slack - Failures
uses: slackapi/[email protected]
if: ${{ job.status != 'success' }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEPLOYMENT_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Devnet Deployment - Failed"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Job Status>"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Commit SHA: <${{ github.server_url }}/${{ github.repository }}/tree/${{ github.sha }}|${{ github.sha }}>\nBranch: <${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}|${{ github.ref_name}}>"
}
}
]
}
pandoras_box_eoa:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box EOA
needs: deploy_devnet
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
with:
runner: devnet
environment: devnet
transaction_batch: '200'
transaction_count: '10000'
mode: EOA
pandoras_box_erc20:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box ERC20
needs: deploy_devnet
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
with:
runner: devnet
environment: devnet
transaction_batch: '200'
transaction_count: '10000'
mode: ERC20
pandoras_box_erc721:
uses: ./.github/workflows/pandoras_box.yml
name: Pandora's Box ERC721
needs: deploy_devnet
secrets:
SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }}
PANDORAS_TARGET: ${{ secrets.PANDORAS_TARGET }}
PANDORAS_MNEMONIC: ${{ secrets.PANDORAS_MNEMONIC }}
with:
runner: devnet
environment: devnet
transaction_batch: '200'
transaction_count: '10000'
mode: ERC721