-
Notifications
You must be signed in to change notification settings - Fork 3
172 lines (165 loc) · 6.83 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
name: deploy
on:
push:
branches: [main, dev]
tags: ['v*.*.*']
env:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
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 }}
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}}" == "dev" || "${{github.ref}}" == "refs/heads/dev" ]]; then
echo "Setting dev environment"
echo "environment=dev" >> $GITHUB_OUTPUT
fi
deploy:
runs-on: ubuntu-latest
needs: init
environment: ${{ needs.init.outputs.environment }}
steps:
# https://github.com/actions/checkout/releases/tag/v3.5.3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Set up Python
# https://github.com/actions/setup-python/releases/tag/v4.7.0
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: 3.9
- 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 Dependencies
run: |
pip -q --no-input install poetry
make install
- name: Linters
run: |
poetry run make check
- name: Deploy Lambdas Dev
if: ${{ needs.init.outputs.environment == 'dev' }}
run: |
make deploy-lambdas-ci stage=dev
env:
API_PORT: 3001
HATHOR_CORE_DOMAIN: node.explorer.testnet.hathor.network
HATHOR_NODES: node1.testnet.hathor.network,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 Lambdas Testnet
if: ${{ needs.init.outputs.environment == 'testnet' }}
run: |
make deploy-lambdas-ci stage=testnet
env:
API_PORT: 3001
HATHOR_CORE_DOMAIN: node.explorer.testnet.hathor.network
HATHOR_NODES: node1.testnet.hathor.network,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 Lambdas Mainnet
if: ${{ needs.init.outputs.environment == 'mainnet' }}
run: |
make deploy-lambdas-ci stage=mainnet
env:
API_PORT: 3001
HATHOR_CORE_DOMAIN: node.explorer.hathor.network
HATHOR_NODES: node.explorer.hathor.network,node1.mainnet.hathor.network,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 Dev
if: ${{ needs.init.outputs.environment == 'dev' }}
run: |
timestamp=`date +%s`; \
export DOCKER_IMAGE_TAG=dev-${{ github.sha }}-$timestamp
make deploy-daemons
- name: Deploy Daemons Testnet
if: ${{ needs.init.outputs.environment == 'testnet' }}
run: |
timestamp=`date +%s`; \
export DOCKER_IMAGE_TAG=testnet-${{ github.sha }}-$timestamp
make deploy-daemons
- name: Deploy Daemons Mainnet
if: ${{ needs.init.outputs.environment == 'mainnet' }}
run: |
export DOCKER_IMAGE_TAG=${GITHUB_REF#refs/*/}
make deploy-daemons
- name: Clean
run: |
rm /home/runner/.docker/config.json