Skip to content

Commit

Permalink
refactor: add a reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
luislhl committed Aug 8, 2024
1 parent fb4aa32 commit b9b2935
Show file tree
Hide file tree
Showing 2 changed files with 253 additions and 166 deletions.
139 changes: 139 additions & 0 deletions .github/reusable-workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# .github/workflows/deploy.yml
name: Deploy

permissions:
id-token: write
contents: read

env:
ELASTIC_SEARCH_TIMEOUT: 25
ELASTIC_RESULTS_PER_PAGE: 10
NODE_CACHE_TTL: 30

on:
workflow_call:
inputs:
aws_region:
description: 'AWS Region'
required: true
type: string
aws_iam_role:
description: 'AWS IAM Role'
required: true
type: string
aws_secret_arn:
description: 'AWS Secret ARN'
required: true
type: string
serverless_stage:
description: 'Serverless Stage'
required: true
type: string
docker_image_tag:
description: 'Docker Image Tag'
required: false
default: ''
type: string
api_port:
description: 'API Port'
required: true
type: string
hathor_core_url:
description: 'Hathor Core URL'
required: true
type: string
hathor_nodes:
description: 'Hathor Nodes'
required: true
type: string
redis_key_prefix:
description: 'Redis Key Prefix'
required: true
type: string
redis_port:
description: 'Redis Port'
required: true
type: string
redis_db:
description: 'Redis DB'
required: true
type: string
metadata_bucket:
description: 'Metadata Bucket'
required: true
type: string
cors_allowed_regex:
description: 'CORS Allowed Regex'
required: true
type: string
elastic_index:
description: 'Elastic Index'
required: true
type: string
elastic_tx_index:
description: 'Elastic TX Index'
required: true
type: string
elastic_token_balances_index:
description: 'Elastic Token Balances Index'
required: true
type: string
healthcheck_hathor_core_enabled:
description: 'Healthcheck Hathor Core Enabled'
required: true
type: boolean
healthcheck_wallet_service_db_enabled:
description: 'Healthcheck Wallet Service DB Enabled'
required: true
type: boolean
healthcheck_elasticsearch_enabled:
description: 'Healthcheck Elasticsearch Enabled'
required: true
type: boolean
healthcheck_redis_enabled:
description: 'Healthcheck Redis Enabled'
required: true
type: boolean

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Prepare deploy
uses: ./.github/actions/prepare-deploy
with:
aws_region: ${{ inputs.aws_region }}
aws_iam_role: ${{ inputs.aws_iam_role }}
aws_secret_arn: ${{ inputs.aws_secret_arn }}

- name: Deploy Lambdas
run: |
make deploy-lambdas-ci stage=${{ inputs.serverless_stage }}
env:
AWS_DEFAULT_REGION: ${{ inputs.aws_region }}
API_PORT: ${{ inputs.api_port }}
HATHOR_CORE_URL: ${{ inputs.hathor_core_url }}
HATHOR_NODES: ${{ inputs.hathor_nodes }}
REDIS_KEY_PREFIX: ${{ inputs.redis_key_prefix }}
REDIS_PORT: ${{ inputs.redis_port }}
REDIS_DB: ${{ inputs.redis_db }}
METADATA_BUCKET: ${{ inputs.metadata_bucket }}
CORS_ALLOWED_REGEX: ${{ inputs.cors_allowed_regex }}
ELASTIC_INDEX: ${{ inputs.elastic_index }}
ELASTIC_TX_INDEX: ${{ inputs.elastic_tx_index }}
ELASTIC_TOKEN_BALANCES_INDEX: ${{ inputs.elastic_token_balances_index }}
HEALTHCHECK_HATHOR_CORE_ENABLED: ${{ inputs.healthcheck_hathor_core_enabled }}
HEALTHCHECK_WALLET_SERVICE_DB_ENABLED: ${{ inputs.healthcheck_wallet_service_db_enabled }}
HEALTHCHECK_ELASTICSEARCH_ENABLED: ${{ inputs.healthcheck_elasticsearch_enabled }}
HEALTHCHECK_REDIS_ENABLED: ${{ inputs.healthcheck_redis_enabled }}

- name: Deploy Daemons
# Deploy only if the inputs.docker_image_tag is not empty
if: ${{ inputs.docker_image_tag != '' }}
run: |
export DOCKER_IMAGE_TAG=${{ inputs.docker_image_tag }}
make deploy-daemons
rm /home/runner/.docker/config.json
Loading

0 comments on commit b9b2935

Please sign in to comment.