Merge pull request #223 from OasisDEX/feat/jt/spark-sl-support #179
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: | |
- dev | |
name: Deploy to AWS Staging | |
jobs: | |
deploy: | |
name: Deploy | |
runs-on: ubuntu-latest | |
env: | |
AWS_REGION: eu-central-1 | |
ECR_REPO_NAME: cache-staging | |
GOERLI_ETL_SERVICE_NAME: cache-etl-goerli-staging | |
GOERLI_API_SERVICE_NAME: cache-api-goerli-staging | |
MAINNET_ETL_SERVICE_NAME: cache-etl-mainnet-staging | |
MAINNET_API_SERVICE_NAME: cache-api-mainnet-staging | |
CLUSTER_NAME: cache-staging | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.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 | |
- name: Update ${{ env.GOERLI_ETL_SERVICE_NAME }} ECS service with latest Docker image | |
id: service-update-goerli-etl | |
run: | | |
aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.GOERLI_ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION | |
- name: Update ${{ env.GOERLI_API_SERVICE_NAME }} ECS service with latest Docker image | |
id: service-update-goerli-api | |
run: | | |
aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.GOERLI_API_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION | |
- name: Update ${{ env.MAINNET_ETL_SERVICE_NAME }} ECS service with latest Docker image | |
id: service-update-mainnet-etl | |
run: | | |
aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.MAINNET_ETL_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION | |
- name: Update ${{ env.MAINNET_API_SERVICE_NAME }} ECS service with latest Docker image | |
id: service-update-mainnet-api | |
run: | | |
aws ecs update-service --cluster $CLUSTER_NAME --service ${{ env.MAINNET_API_SERVICE_NAME }} --force-new-deployment --region $AWS_REGION | |
- name: Wait for goerli services to become stable | |
uses: oryanmoshe/[email protected] | |
with: | |
ecs-cluster: ${{ env.CLUSTER_NAME }} | |
ecs-services: '["${{ env.GOERLI_ETL_SERVICE_NAME }}", "${{ env.GOERLI_API_SERVICE_NAME }}"]' | |
- name: Wait for mainnet services to become stable | |
uses: oryanmoshe/[email protected] | |
with: | |
ecs-cluster: ${{ env.CLUSTER_NAME }} | |
ecs-services: '["${{ env.MAINNET_ETL_SERVICE_NAME }}", "${{ env.MAINNET_API_SERVICE_NAME }}"]' |