Skip to content

Merge pull request #240 from OasisDEX/dev #51

Merge pull request #240 from OasisDEX/dev

Merge pull request #240 from OasisDEX/dev #51

Workflow file for this run

on:
push:
branches:
- master
name: Deploy to AWS Production
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
env:
AWS_REGION: us-east-1
ECR_REPO_NAME: cache-prod
ETL_SERVICE_NAME: cache-etl-mainnet-prod
API_SERVICE_NAME: cache-api-mainnet-prod
CLUSTER_NAME: cache-prod
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.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/[email protected]
with:
ecs-cluster: ${{ env.CLUSTER_NAME }}
ecs-services: '["${{ env.ETL_SERVICE_NAME }}", "${{ env.API_SERVICE_NAME }}"]'