fix migration conflict #60
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
GOERLI_ETL_SERVICE_NAME: polling-db2-goerli-staging-etl | |
GOERLI_API_SERVICE_NAME: polling-db2-goerli-staging-api | |
GOERLI_CLUSTER_NAME: polling-db2-goerli-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 goerli | |
- name: Update ${{ env.GOERLI_ETL_SERVICE_NAME }} ECS service with latest Docker image | |
id: service-update-etl-goerli | |
run: | | |
aws ecs update-service --cluster $GOERLI_CLUSTER_NAME --service ${{ env.GOERLI_ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION | |
# API goerli | |
- name: Update ${{ env.GOERLI_API_SERVICE_NAME }} ECS service with latest Docker image | |
id: service-update-api-goerli | |
run: | | |
aws ecs update-service --cluster $GOERLI_CLUSTER_NAME --service ${{ env.GOERLI_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.GOERLI_CLUSTER_NAME }} cluster | |
uses: oryanmoshe/ecs-wait-action@v1.3 | |
with: | |
ecs-cluster: ${{ env.GOERLI_CLUSTER_NAME }} | |
ecs-services: '["${{ env.GOERLI_ETL_SERVICE_NAME }}", "${{ env.GOERLI_API_SERVICE_NAME }}"]' |