Skip to content

Merge pull request #170 from makerdao/multi_tenderly #69

Merge pull request #170 from makerdao/multi_tenderly

Merge pull request #170 from makerdao/multi_tenderly #69

Workflow file for this run

on:
push:
branches:
- staging
name: Deploy polling-db2 to AWS Staging
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
env:
AWS_REGION: eu-central-1
ECR_REPO_NAME: polling-db2-mainnet-staging
MAINNET_ETL_SERVICE_NAME: polling-db2-mainnet-staging-etl
MAINNET_API_SERVICE_NAME: polling-db2-mainnet-staging-api
MAINNET_CLUSTER_NAME: polling-db2-mainnet-staging
TENDERLY_ETL_SERVICE_NAME: polling-db2-tenderly-staging-etl
TENDERLY_API_SERVICE_NAME: polling-db2-tenderly-staging-api
TENDERLY_CLUSTER_NAME: polling-db2-tenderly-staging
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.POLLINGDB2_STAGING_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.POLLINGDB2_STAGING_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Extract commit hash
id: vars
shell: bash
run: |
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
SHA_TAG: ${{ steps.vars.outputs.sha_short }}
LATEST_TAG: latest
ENVIRONMENT_TAG: staging
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPO_NAME:$SHA_TAG \
-t $ECR_REGISTRY/$ECR_REPO_NAME:$LATEST_TAG \
-t $ECR_REGISTRY/$ECR_REPO_NAME:$ENVIRONMENT_TAG \
.
docker push $ECR_REGISTRY/$ECR_REPO_NAME --all-tags
# ETL mainnet
- name: Update ${{ env.MAINNET_ETL_SERVICE_NAME }} ECS service with latest Docker image
id: service-update-etl-mainnet
run: |
aws ecs update-service --cluster $MAINNET_CLUSTER_NAME --service ${{ env.MAINNET_ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION
# API mainnet
- name: Update ${{ env.MAINNET_API_SERVICE_NAME }} ECS service with latest Docker image
id: service-update-api-mainnet
run: |
aws ecs update-service --cluster $MAINNET_CLUSTER_NAME --service ${{ env.MAINNET_API_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION
# ETL tenderly
- name: Update ${{ env.TENDERLY_ETL_SERVICE_NAME }} ECS service with latest Docker image
id: service-update-etl-tenderly
run: |
aws ecs update-service --cluster $TENDERLY_CLUSTER_NAME --service ${{ env.TENDERLY_ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION
# API tenderly
- name: Update ${{ env.TENDERLY_API_SERVICE_NAME }} ECS service with latest Docker image
id: service-update-api-tenderly
run: |
aws ecs update-service --cluster $TENDERLY_CLUSTER_NAME --service ${{ env.TENDERLY_API_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION
# Wait for all containers
- name: Wait for all services to become stable on ${{ env.MAINNET_CLUSTER_NAME }} cluster
uses: oryanmoshe/ecs-wait-action@v1.3
with:
ecs-cluster: ${{ env.MAINNET_CLUSTER_NAME }}
ecs-services: '["${{ env.MAINNET_ETL_SERVICE_NAME }}", "${{ env.MAINNET_API_SERVICE_NAME }}"]'
- name: Wait for all services to become stable on ${{ env.TENDERLY_CLUSTER_NAME }} cluster
uses: oryanmoshe/ecs-wait-action@v1.3
with:
ecs-cluster: ${{ env.TENDERLY_CLUSTER_NAME }}
ecs-services: '["${{ env.TENDERLY_ETL_SERVICE_NAME }}", "${{ env.TENDERLY_API_SERVICE_NAME }}"]'