Merge pull request #324 from HathorNetwork/dev #208
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |