Skip to content

fix: ci workflow syntax #217

fix: ci workflow syntax

fix: ci workflow syntax #217

Workflow file for this run

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

Check failure on line 92 in .github/workflows/deploy.yml

View workflow run for this annotation

GitHub Actions / deploy

Invalid workflow file

The workflow is not valid. .github/workflows/deploy.yml (Line: 92, Col: 12): Job 'deploy-dev' depends on unknown job 'init, dependencies'. .github/workflows/deploy.yml (Line: 156, Col: 12): Job 'deploy-testnet' depends on unknown job '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: Set up Python
# https://github.com/actions/setup-python/releases/tag/v4.7.0
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: 3.9
# This step will parse the JSON secret from AWS Secrets Manager into environment variables
- 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: Install Python Dependencies
run: |
pip -q --no-input install poetry
poetry install
- name: Linters
run: |
poetry run make check
- 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
# https://github.com/actions/setup-python/releases/tag/v4.7.0
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: 3.9
- name: Install Python Dependencies
run: |
pip -q --no-input install poetry
poetry install
- name: Linters
run: |
poetry run make check
- 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
# https://github.com/actions/setup-python/releases/tag/v4.7.0
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: 3.9
- name: Install Python Dependencies
run: |
pip -q --no-input install poetry
poetry install
- name: Linters
run: |
poetry run make check
- 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