forked from InjectiveLabs/injective-lists
-
Notifications
You must be signed in to change notification settings - Fork 0
229 lines (193 loc) · 7.38 KB
/
master.yaml
File metadata and controls
229 lines (193 loc) · 7.38 KB
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
name: Injective list - Generate data
on:
workflow_dispatch:
schedule:
- cron: "*/15 * * * *"
push:
branches:
- master
jobs:
generate:
if: ${{ !contains(github.event.commits[0].message, 'generate json files') }}
name: "Regenerate JSON files"
runs-on: blacksmith-8vcpu-ubuntu-2204
permissions: write-all
env:
## Github Actions
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
CLOUD_FLARE_API_KEY: ${{ secrets.CLOUD_FLARE_API_KEY }}
CLOUD_FLARE_ACCOUNT_ID: ${{ secrets.CLOUD_FLARE_ACCOUNT_ID }}
CLOUD_FLARE_ACCOUNT_HASH: ${{ secrets.CLOUD_FLARE_ACCOUNT_HASH }}
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
ALCHEMY_GOERLI_KEY: ${{ secrets.ALCHEMY_GOERLI_KEY }}
ALCHEMY_SEPOLIA_KEY: ${{ secrets.ALCHEMY_SEPOLIA_KEY }}
MAINNET_FEE_PAYER: ${{ secrets.MAINNET_FEE_PAYER }}
TESTNET_FEE_PAYER: ${{ secrets.TESTNET_FEE_PAYER }}
DEVNET_FEE_PAYER: ${{ secrets.DEVNET_FEE_PAYER }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
token: "${{ secrets.GH_TOKEN }}"
- run: |
git reset --hard origin/master
- name: Install dependencies
run: cd src && yarn
- name: Generate tokens
uses: borales/actions-yarn@v4
with:
cmd: generate:tokens
dir: "src"
- name: Generate validators
uses: borales/actions-yarn@v4
with:
cmd: generate:validators
dir: "src"
- name: Generate market slugs
uses: borales/actions-yarn@v4
with:
cmd: generate:slugs
dir: "src"
- name: Generate wasm messages
uses: borales/actions-yarn@v4
with:
cmd: generate:wasm
dir: "src"
- name: Generate verified denoms
uses: borales/actions-yarn@v4
with:
cmd: generate:verifiedDenoms
dir: "src"
- name: Generate restriction list
uses: borales/actions-yarn@v4
with:
cmd: generate:restriction
dir: "src"
- name: Generate swap routes
uses: borales/actions-yarn@v4
with:
cmd: generate:swap:routes
dir: "src"
- name: Generate configs
uses: borales/actions-yarn@v4
with:
cmd: generate:configs
dir: "src"
- name: Commit generated files
run: |
[ -z "$(git config user.name)" ] && git config --global user.name "GitHub Actions"
[ -z "$(git config user.email)" ] && git config --global user.email "actions@github.com"
git add .
# Check if there are any changes to commit
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit"
exit 0
fi
if [[ "${{ contains(github.event.commits[0].message, 'skip deploy') }}" == "true" || "${{ github.event_name != 'push' }}" == "true" ]]; then
git commit -m "chore: generate json files - skip deploy" --no-verify
else
git commit -m "chore: generate json files" --no-verify
fi
git push origin HEAD:master
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
# - name: Commit changes
# uses: EndBug/add-and-commit@v9
# if: ${{ github.event_name == 'push' && !contains(github.event.commits[0].message, 'skip deploy') }}
# with:
# message: "chore: generate json files"
# - name: Commit changes
# uses: EndBug/add-and-commit@v9
# if: ${{ github.event_name != 'push' || contains(github.event.commits[0].message, 'skip deploy') }}
# with:
# message: "chore: generate json files - skip deploy"
deployAws:
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' && !contains(github.event.commits[0].message, 'skip deploy') }}
name: "Deploy AWS"
runs-on: ubuntu-latest
needs: generate
steps:
- name: Sleep for 30s
if: ${{ env.SKIP_DEPLOYMENTS != 'true' }}
uses: juliangruber/sleep-action@v2.0.0
with:
time: 30s
# This is here solely for testing and running this action locally with ACT - it shouldn't be needed for running on github as the images in gh actions should already have the AWS CLI installed
- name: Install Act dependencies
if: ${{ env.ACT }}
run: |
apt-get update && apt-get install sudo -y && apt-get install wget -y && apt-get install unzip -y
- name: Install AWS if running locally
if: ${{ env.ACT }}
uses: unfor19/install-aws-cli-action@v1
with:
version: 2 # default
verbose: true # default
arch: amd64 # allowed values: amd64, arm64
- name: Checkout with retry
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 2
token: ${{ secrets.GH_TOKEN }}
- name: Setup AWS CLI
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Sync files to S3 bucket
run: |
aws s3 sync json s3://injective-lists/json --delete \
--cache-control "public, max-age=31536000, s-maxage=31536000"
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"
- name: Sleep for 60s
if: ${{ env.SKIP_DEPLOYMENTS != 'true' }}
uses: juliangruber/sleep-action@v2.0.0
with:
time: 60s
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"
deployAwsStaging:
if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' && !contains(github.event.commits[0].message, 'skip deploy') }}
name: "Deploy AWS Staging"
runs-on: ubuntu-latest
needs: generate
steps:
- name: Sleep for 30s
uses: juliangruber/sleep-action@v2.0.0
with:
time: 30s
- name: Install Act dependencies
if: ${{ env.ACT }}
run: |
apt-get update && apt-get install sudo -y && apt-get install wget -y && apt-get install unzip -y
- name: Install AWS if running locally
if: ${{ env.ACT }}
uses: unfor19/install-aws-cli-action@v1
with:
version: 2 # default
verbose: true # default
arch: amd64 # allowed values: amd64, arm64
- name: Checkout with retry
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 2
token: ${{ secrets.GH_TOKEN }}
- name: Setup AWS CLI
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- name: Sync files to S3 bucket
run: |
aws s3 sync json s3://injective-lists-staging/json --delete \
--cache-control "public, max-age=31536000, s-maxage=31536000"
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.STAGING_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"