name: Deploy to Production BFF on: push: branches: [production-bff] jobs: build: name: Build Image runs-on: ubuntu-latest steps: - name: Check out code uses: actions/checkout@v2 - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: us-west-1 - name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v1 - name: Build image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: indeehub_ecr_repo_production_bff IMAGE_TAG: latest run: | docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . - name: Tag image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: indeehub_ecr_repo_production_bff IMAGE_TAG: latest run: | CURRENT_SHA=${GITHUB_SHA::8} docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:${CURRENT_SHA} - name: Push image to Amazon ECR env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: indeehub_ecr_repo_production_bff IMAGE_TAG: latest run: | docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - name: Restart ECS Cluster env: CLUSTER_NAME: indeehub-cluster-production-bff SERVICE_NAME: indeehub-api-service-production-bff run: | aws ecs update-service --cluster $CLUSTER_NAME --service $SERVICE_NAME --force-new-deployment