Skip to content

Merge pull request #167 from makerdao/release/conflict-fix #25

Merge pull request #167 from makerdao/release/conflict-fix

Merge pull request #167 from makerdao/release/conflict-fix #25

Workflow file for this run

on:
push:
branches:
- master
name: Deploy polling-db2 to AWS Prod
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
env:
AWS_REGION: us-east-1
ECR_REPO_NAME: polling-db2-mainnet-prod
ETL_SERVICE_NAME: polling-db2-mainnet-prod-etl
API_SERVICE_NAME: polling-db2-mainnet-prod-api
CLUSTER_NAME: polling-db2-mainnet-prod
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_PROD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.POLLINGDB2_PROD_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: prod
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
- name: Update ${{ env.ETL_SERVICE_NAME }} ECS service with latest Docker image
id: service-update-etl
run: |
aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION
- name: Update ${{ env.API_SERVICE_NAME }} ECS service with latest Docker image
id: service-update-api
run: |
aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.API_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION
- name: Wait for all services to become stable
uses: oryanmoshe/ecs-wait-action@v1.3
with:
ecs-cluster: ${{ env.CLUSTER_NAME }}
ecs-services: '["${{ env.ETL_SERVICE_NAME }}", "${{ env.API_SERVICE_NAME }}"]'