-
Notifications
You must be signed in to change notification settings - Fork 3
235 lines (222 loc) · 9.31 KB
/
deploy.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
name: deploy
on:
push:
branches: [main, dev, ci/iam-roles-and-aws-secrets]
tags: ['v*.*.*']
env:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_DEFAULT_REGION: 'eu-central-1'
AWS_VPC_DEFAULT_SG_ID: ${{ secrets.AWS_VPC_DEFAULT_SG_ID }}
AWS_SUBNET_ID_1: ${{ secrets.AWS_SUBNET_ID_1 }}
AWS_SUBNET_ID_2: ${{ secrets.AWS_SUBNET_ID_2 }}
AWS_SUBNET_ID_3: ${{ secrets.AWS_SUBNET_ID_3 }}
ELASTIC_CLOUD_ID: ${{ secrets.ELASTIC_CLOUD_ID }}
ELASTIC_USER: ${{ secrets.ELASTIC_USER }}
ELASTIC_PASSWORD: ${{ secrets.ELASTIC_PASSWORD }}
ELASTIC_SEARCH_TIMEOUT: 25
ELASTIC_RESULTS_PER_PAGE: 10
WALLET_SERVICE_DB_USERNAME: ${{ secrets.WALLET_SERVICE_DB_USERNAME }}
WALLET_SERVICE_DB_PASSWORD: ${{ secrets.WALLET_SERVICE_DB_PASSWORD }}
WALLET_SERVICE_DB_HOST: ${{ secrets.WALLET_SERVICE_DB_HOST }}
WALLET_SERVICE_DB_NAME: ${{ secrets.WALLET_SERVICE_DB_NAME }}
permissions:
id-token: write
contents: read
jobs:
init:
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.setenv.outputs.environment}}
steps:
- name: Set environment
id: setenv
run: |
if [[ "${{github.ref}}" == refs/tags/v* ]]; then
echo "Setting mainnet environment"
echo "environment=mainnet" >> $GITHUB_OUTPUT
elif [[ "${{github.base_ref}}" == "main" || "${{github.ref}}" == "refs/heads/main" ]]; then
echo "Setting testnet environment"
echo "environment=testnet" >> $GITHUB_OUTPUT
elif [[ "${{github.base_ref}}" == "ci/iam-roles-and-aws-secrets" || "${{github.ref}}" == "refs/heads/ci/iam-roles-and-aws-secrets" ]]; then
echo "Setting dev environment"
echo "environment=dev" >> $GITHUB_OUTPUT
elif [[ "${{github.base_ref}}" == "dev" || "${{github.ref}}" == "refs/heads/dev" ]]; then
echo "Setting dev environment"
echo "environment=dev" >> $GITHUB_OUTPUT
fi
dependencies:
runs-on: ubuntu-latest
steps:
# https://github.com/actions/checkout/releases/tag/v3.5.3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Set up Node.js 18.x
# https://github.com/actions/setup-node/releases/tag/v3.7.0
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8
with:
node-version: 18.x
- name: Cache node modules
# https://github.com/actions/cache/releases/tag/v3.3.1
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: /home/runner/work/hathor-explorer/hathor-explorer/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Npm Dependencies
run: |
npm ci
- name: Pack node modules
run: |
tar -cvf node_modules.tar ./node_modules
- name: Upload node modules
uses: actions/upload-artifact@v2
with:
name: node_modules
path: node_modules.tar
if-no-files-found: error
retention-days: 1
deploy-dev:
runs-on: ubuntu-latest
needs: [init, dependencies]
if: ${{ needs.init.outputs.environment == 'dev' }}
steps:
# https://github.com/actions/checkout/releases/tag/v3.5.3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Configure AWS Credentials
# https://github.com/aws-actions/configure-aws-credentials/releases/tag/v4.0.2
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
aws-region: eu-central-1
role-to-assume: arn:aws:iam::769498303037:role/ExplorerServiceGitHubActionsRole
- name: Step name
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
arn:aws:secretsmanager:eu-central-1:769498303037:secret:ExplorerService/dev-0ikehC
parse-json-secrets: true
- name: Check env
run: |
env
- name: Set up Python and Dependencies
uses: ./.github/workflows/lib/setup-python
with:
python_version: 3.9
- name: Deploy Lambdas Dev
run: |
make deploy-lambdas-ci stage=dev
env:
API_PORT: 3001
HATHOR_CORE_URL: https://node.explorer.testnet.hathor.network
HATHOR_NODES: https://node1.testnet.hathor.network,https://node.explorer.testnet.hathor.network
REDIS_KEY_PREFIX: hathor-explorer-service-dev
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_PORT: 6379
REDIS_DB: 0
METADATA_BUCKET: hathor-explorer-metadata-dev
CORS_ALLOWED_REGEX: .*
NODE_CACHE_TTL: 30
ELASTIC_INDEX: dev-token
ELASTIC_TX_INDEX: dev-tx
ELASTIC_TOKEN_BALANCES_INDEX: dev-token-balance
HEALTHCHECK_HATHOR_CORE_ENABLED: True
HEALTHCHECK_WALLET_SERVICE_DB_ENABLED: True
HEALTHCHECK_ELASTICSEARCH_ENABLED: True
HEALTHCHECK_REDIS_ENABLED: True
- name: Deploy Daemons Dev
run: |
timestamp=`date +%s`; \
export DOCKER_IMAGE_TAG=dev-${{ github.sha }}-$timestamp
make deploy-daemons
rm /home/runner/.docker/config.json
deploy-testnet:
runs-on: ubuntu-latest
needs: [init, dependencies]
if: ${{ needs.init.outputs.environment == 'testnet' }}
steps:
# https://github.com/actions/checkout/releases/tag/v3.5.3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Configure AWS Credentials
# https://github.com/aws-actions/configure-aws-credentials/releases/tag/v4.0.2
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
aws-region: eu-central-1
role-to-assume: arn:aws:iam::769498303037:role/ExplorerServiceGitHubActionsRole
- name: Set up Python and Dependencies
uses: ./.github/workflows/lib/setup-python
with:
python_version: 3.9
- name: Deploy Lambdas Testnet
run: |
make deploy-lambdas-ci stage=testnet
env:
API_PORT: 3001
HATHOR_CORE_URL: https://node.explorer.testnet.hathor.network
HATHOR_NODES: https://node1.testnet.hathor.network,https://node.explorer.testnet.hathor.network
REDIS_KEY_PREFIX: hathor-explorer-service-testnet
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_PORT: 6379
REDIS_DB: 0
METADATA_BUCKET: hathor-explorer-metadata-testnet
CORS_ALLOWED_REGEX: https?:\/\/([a-z0-9]*\.){0,5}hathor\.network
NODE_CACHE_TTL: 30
ELASTIC_INDEX: testnet-token
ELASTIC_TX_INDEX: testnet-tx
ELASTIC_TOKEN_BALANCES_INDEX: testnet-token-balance
HEALTHCHECK_HATHOR_CORE_ENABLED: True
HEALTHCHECK_WALLET_SERVICE_DB_ENABLED: True
HEALTHCHECK_ELASTICSEARCH_ENABLED: True
HEALTHCHECK_REDIS_ENABLED: True
- name: Deploy Daemons Testnet
run: |
timestamp=`date +%s`; \
export DOCKER_IMAGE_TAG=testnet-${{ github.sha }}-$timestamp
make deploy-daemons
rm /home/runner/.docker/config.json
deploy-mainnet:
runs-on: ubuntu-latest
needs: [init, dependencies]
if: ${{ needs.init.outputs.environment == 'mainnet' }}
steps:
# https://github.com/actions/checkout/releases/tag/v3.5.3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Configure AWS Credentials
# https://github.com/aws-actions/configure-aws-credentials/releases/tag/v4.0.2
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
with:
aws-region: eu-central-1
role-to-assume: arn:aws:iam::769498303037:role/ExplorerServiceGitHubActionsRole
- name: Set up Python and Dependencies
uses: ./.github/workflows/lib/setup-python
with:
python_version: 3.9
- name: Deploy Lambdas Mainnet
run: |
make deploy-lambdas-ci stage=mainnet
env:
API_PORT: 3001
HATHOR_CORE_URL: https://node.explorer.hathor.network
HATHOR_NODES: https://node.explorer.hathor.network,https://node1.mainnet.hathor.network,https://node2.mainnet.hathor.network
REDIS_KEY_PREFIX: hathor-explorer-service-mainnet
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_PORT: 6379
REDIS_DB: 0
METADATA_BUCKET: hathor-explorer-metadata-mainnet
CORS_ALLOWED_REGEX: https?:\/\/([a-z0-9]*\.){0,5}hathor\.network
NODE_CACHE_TTL: 30
ELASTIC_INDEX: mainnet-token
ELASTIC_TX_INDEX: mainnet-tx
ELASTIC_TOKEN_BALANCES_INDEX: mainnet-token-balance
HEALTHCHECK_HATHOR_CORE_ENABLED: True
HEALTHCHECK_WALLET_SERVICE_DB_ENABLED: True
HEALTHCHECK_ELASTICSEARCH_ENABLED: True
HEALTHCHECK_REDIS_ENABLED: True
- name: Deploy Daemons Mainnet
run: |
export DOCKER_IMAGE_TAG=${GITHUB_REF#refs/*/}
make deploy-daemons
rm /home/runner/.docker/config.json