1.126.2-PRERELEASE #340
Workflow file for this run
This file contains hidden or 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
| name: Deploy to Dev Environment | |
| on: | |
| release: | |
| types: [prereleased] | |
| permissions: {} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.release.tag_name }} | |
| cancel-in-progress: false | |
| env: | |
| AWS_REGION: 'us-west-2' | |
| jobs: | |
| build-web: | |
| name: Build Web Image | |
| runs-on: ubuntu-22.04 | |
| environment: staging | |
| outputs: | |
| image: ${{ steps.build-image.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: true | |
| ref: ${{ github.head_ref }} | |
| token: ${{ secrets.PAT }} | |
| persist-credentials: false | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1 | |
| with: | |
| aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@fa648b43de3d4d023bcb3f89ed6940096949c419 # v2.1.5 | |
| - name: Build, tag, and push image to Amazon ECR | |
| id: build-image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| IMAGE_TAG: ${{ github.event.release.tag_name }} | |
| ECR_REPOSITORY: 'advisingapp' | |
| run: | | |
| # Build a docker container and | |
| # push it to ECR so that it can | |
| # be deployed to ECS. | |
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --target web-deploy --platform linux/amd64 . | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
| echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT | |
| deploy-web: | |
| name: Deploy Web Service | |
| runs-on: ubuntu-22.04 | |
| needs: [build-web, deploy-worker] | |
| environment: staging | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: true | |
| ref: ${{ github.head_ref }} | |
| token: ${{ secrets.PAT }} | |
| persist-credentials: false | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1 | |
| with: | |
| aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Fill in the new image ID in the Amazon ECS task definition | |
| id: task-def | |
| uses: aws-actions/amazon-ecs-render-task-definition@6853cfae8c3a7d978fbf68b5a55453395541dfbb # v1.8.5 | |
| with: | |
| task-definition: 'docker/devops/ecs/advisingapp/advisingapp-dev-task-definition.json' | |
| container-name: 'app' | |
| image: ${{ needs.build-web.outputs.image }} | |
| - name: Deploy Amazon ECS task definition | |
| id: task-deploy | |
| uses: aws-actions/amazon-ecs-deploy-task-definition@a310a830f5c14e583e35d84e4e1ec7dd177c3c9c # v2.6.2 | |
| with: | |
| task-definition: ${{ steps.task-def.outputs.task-definition }} | |
| service: 'advisingapp-dev-service' | |
| cluster: 'advisingapp-dev' | |
| wait-for-service-stability: true | |
| - name: Check if deployment was successful | |
| id: check-deployment | |
| run: | | |
| CURRENT_TASK_DEF_ARN=$(aws ecs describe-services --cluster advisingapp-dev --services advisingapp-dev-service --query services[0].deployments[0].taskDefinition | jq -r ".") | |
| NEW_TASK_DEF_ARN=${STEPS_TASK_DEPLOY_OUTPUTS_TASK_DEFINITION_ARN} | |
| echo "Current task arn: $CURRENT_TASK_DEF_ARN" | |
| echo "New task arn: $NEW_TASK_DEF_ARN" | |
| if [ "$CURRENT_TASK_DEF_ARN" != "$NEW_TASK_DEF_ARN" ]; then | |
| echo "Deployment failed." | |
| exit 1 | |
| fi | |
| env: | |
| STEPS_TASK_DEPLOY_OUTPUTS_TASK_DEFINITION_ARN: ${{ steps.task-deploy.outputs.task-definition-arn }} | |
| build-worker: | |
| name: Build Worker Image | |
| runs-on: ubuntu-22.04 | |
| environment: staging | |
| outputs: | |
| image: ${{ steps.build-image.outputs.image }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: true | |
| ref: ${{ github.head_ref }} | |
| token: ${{ secrets.PAT }} | |
| persist-credentials: false | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1 | |
| with: | |
| aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@fa648b43de3d4d023bcb3f89ed6940096949c419 # v2.1.5 | |
| - name: Build, tag, and push image to Amazon ECR | |
| id: build-image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| IMAGE_TAG: ${{ github.event.release.tag_name }} | |
| ECR_REPOSITORY: 'advisingapp/worker' | |
| run: | | |
| # Build a docker container and | |
| # push it to ECR so that it can | |
| # be deployed to ECS. | |
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --target worker-deploy --platform linux/amd64 . | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
| echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT | |
| deploy-worker: | |
| name: Deploy Worker Service | |
| runs-on: ubuntu-22.04 | |
| needs: [build-worker] | |
| environment: staging | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: true | |
| ref: ${{ github.head_ref }} | |
| token: ${{ secrets.PAT }} | |
| persist-credentials: false | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1 | |
| with: | |
| aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Fill in the new image ID in the Amazon ECS task definition | |
| id: task-def | |
| uses: aws-actions/amazon-ecs-render-task-definition@6853cfae8c3a7d978fbf68b5a55453395541dfbb # v1.8.5 | |
| with: | |
| task-definition: 'docker/devops/ecs/advisingapp/advisingapp-worker-dev-task-definition.json' | |
| container-name: 'worker' | |
| image: ${{ needs.build-worker.outputs.image }} | |
| - name: Deploy Amazon ECS task definition | |
| id: task-deploy | |
| uses: aws-actions/amazon-ecs-deploy-task-definition@a310a830f5c14e583e35d84e4e1ec7dd177c3c9c # v2.6.2 | |
| with: | |
| task-definition: ${{ steps.task-def.outputs.task-definition }} | |
| service: 'advisingapp-worker-dev-service' | |
| cluster: 'advisingapp-dev' | |
| wait-for-service-stability: true | |
| - name: Check if deployment was successful | |
| id: check-deployment | |
| run: | | |
| CURRENT_TASK_DEF_ARN=$(aws ecs describe-services --cluster advisingapp-dev --services advisingapp-worker-dev-service --query services[0].deployments[0].taskDefinition | jq -r ".") | |
| NEW_TASK_DEF_ARN=${STEPS_TASK_DEPLOY_OUTPUTS_TASK_DEFINITION_ARN} | |
| echo "Current task arn: $CURRENT_TASK_DEF_ARN" | |
| echo "New task arn: $NEW_TASK_DEF_ARN" | |
| if [ "$CURRENT_TASK_DEF_ARN" != "$NEW_TASK_DEF_ARN" ]; then | |
| echo "Deployment failed." | |
| exit 1 | |
| fi | |
| env: | |
| STEPS_TASK_DEPLOY_OUTPUTS_TASK_DEFINITION_ARN: ${{ steps.task-deploy.outputs.task-definition-arn }} | |
| build-scheduler: | |
| name: Build Scheduler Image | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| image: ${{ steps.build-image.outputs.image }} | |
| environment: staging | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: true | |
| ref: ${{ github.head_ref }} | |
| token: ${{ secrets.PAT }} | |
| persist-credentials: false | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1 | |
| with: | |
| aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@fa648b43de3d4d023bcb3f89ed6940096949c419 # v2.1.5 | |
| - name: Build, tag, and push image to Amazon ECR | |
| id: build-image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| IMAGE_TAG: ${{ github.event.release.tag_name }} | |
| ECR_REPOSITORY: 'advisingapp/scheduler' | |
| run: | | |
| # Build a docker container and | |
| # push it to ECR so that it can | |
| # be deployed to ECS. | |
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --target scheduler-deploy --platform linux/amd64 . | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
| echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT | |
| deploy-scheduler: | |
| name: Deploy Scheduler Service | |
| runs-on: ubuntu-22.04 | |
| needs: [build-scheduler, deploy-worker] | |
| environment: staging | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: true | |
| ref: ${{ github.head_ref }} | |
| token: ${{ secrets.PAT }} | |
| persist-credentials: false | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1 | |
| with: | |
| aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Fill in the new image ID in the Amazon ECS task definition | |
| id: task-def | |
| uses: aws-actions/amazon-ecs-render-task-definition@6853cfae8c3a7d978fbf68b5a55453395541dfbb # v1.8.5 | |
| with: | |
| task-definition: 'docker/devops/ecs/advisingapp/advisingapp-scheduler-dev-task-definition.json' | |
| container-name: 'scheduler' | |
| image: ${{ needs.build-scheduler.outputs.image }} | |
| - name: Deploy Amazon ECS task definition | |
| id: task-deploy | |
| uses: aws-actions/amazon-ecs-deploy-task-definition@a310a830f5c14e583e35d84e4e1ec7dd177c3c9c # v2.6.2 | |
| with: | |
| task-definition: ${{ steps.task-def.outputs.task-definition }} | |
| service: 'advisingapp-scheduler-dev-service' | |
| cluster: 'advisingapp-dev' | |
| wait-for-service-stability: true | |
| - name: Check if deployment was successful | |
| id: check-deployment | |
| run: | | |
| CURRENT_TASK_DEF_ARN=$(aws ecs describe-services --cluster advisingapp-dev --services advisingapp-scheduler-dev-service --query services[0].deployments[0].taskDefinition | jq -r ".") | |
| NEW_TASK_DEF_ARN=${STEPS_TASK_DEPLOY_OUTPUTS_TASK_DEFINITION_ARN} | |
| echo "Current task arn: $CURRENT_TASK_DEF_ARN" | |
| echo "New task arn: $NEW_TASK_DEF_ARN" | |
| if [ "$CURRENT_TASK_DEF_ARN" != "$NEW_TASK_DEF_ARN" ]; then | |
| echo "Deployment failed." | |
| exit 1 | |
| fi | |
| env: | |
| STEPS_TASK_DEPLOY_OUTPUTS_TASK_DEFINITION_ARN: ${{ steps.task-deploy.outputs.task-definition-arn }} | |
| build-release-automation: | |
| name: Build Release Automation Image | |
| runs-on: ubuntu-22.04 | |
| outputs: | |
| image: ${{ steps.build-image.outputs.image }} | |
| environment: staging | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: true | |
| ref: ${{ github.head_ref }} | |
| token: ${{ secrets.PAT }} | |
| persist-credentials: false | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1 | |
| with: | |
| aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@fa648b43de3d4d023bcb3f89ed6940096949c419 # v2.1.5 | |
| - name: Build, tag, and push image to Amazon ECR | |
| id: build-image | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| IMAGE_TAG: ${{ github.event.release.tag_name }} | |
| ECR_REPOSITORY: 'advisingapp/release-automation' | |
| run: | | |
| # Build a docker container and | |
| # push it to ECR so that it can | |
| # be deployed to ECS. | |
| docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG --target release-automation --platform linux/amd64 . | |
| docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
| echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT | |
| deploy-release-automation: | |
| name: Deploy and Run Release Automation Service | |
| needs: [deploy-web, deploy-worker, deploy-scheduler, build-release-automation] | |
| runs-on: ubuntu-22.04 | |
| environment: staging | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: true | |
| ref: ${{ github.head_ref }} | |
| token: ${{ secrets.PAT }} | |
| persist-credentials: false | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1 | |
| with: | |
| aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| - name: Fill in the new image ID in the Amazon ECS task definition | |
| id: task-def | |
| uses: aws-actions/amazon-ecs-render-task-definition@6853cfae8c3a7d978fbf68b5a55453395541dfbb # v1.8.5 | |
| with: | |
| task-definition: 'docker/devops/ecs/advisingapp/advisingapp-release-automation-dev-task-definition.json' | |
| container-name: 'release-automation' | |
| image: ${{ needs.build-release-automation.outputs.image }} | |
| - name: Deploy Amazon ECS task definition | |
| uses: aws-actions/amazon-ecs-deploy-task-definition@a310a830f5c14e583e35d84e4e1ec7dd177c3c9c # v2.6.2 | |
| with: | |
| task-definition: ${{ steps.task-def.outputs.task-definition }} | |
| cluster: 'advisingapp-dev' | |
| desired-count: 1 | |
| run-task: true | |
| run-task-security-groups: ${{ secrets.RELEASE_AUTOMATION_SECURITY_GROUPS }} | |
| run-task-subnets: ${{ secrets.RELEASE_AUTOMATION_SUBNETS }} | |
| run-task-assign-public-IP: 'DISABLED' | |
| run-task-launch-type: 'FARGATE' | |
| wait-for-task-stopped: true |