|
| 1 | +name: Deploy AI Services to AWS Fargate |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +env: |
| 9 | + AWS_REGION: ${{ secrets.AWS_REGION }} |
| 10 | + ECR_REGISTRY: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com |
| 11 | + |
| 12 | +jobs: |
| 13 | + deploy-captioning: |
| 14 | + name: Deploy Captioning Service |
| 15 | + runs-on: ubuntu-latest |
| 16 | + if: "contains(github.event.head_commit.message, '[force deploy]') || contains(join(github.event.commits.*.modified), 'captioning-service/') || contains(join(github.event.commits.*.added), 'captioning-service/')" |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v3 |
| 21 | + |
| 22 | + - name: Configure AWS credentials |
| 23 | + uses: aws-actions/configure-aws-credentials@v2 |
| 24 | + with: |
| 25 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 26 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 27 | + aws-region: ${{ env.AWS_REGION }} |
| 28 | + |
| 29 | + - name: Login to Amazon ECR |
| 30 | + id: login-ecr |
| 31 | + uses: aws-actions/amazon-ecr-login@v1 |
| 32 | + |
| 33 | + - name: Build, tag, and push image to Amazon ECR |
| 34 | + id: build-image |
| 35 | + env: |
| 36 | + ECR_REPOSITORY: captioning-service |
| 37 | + IMAGE_TAG: ${{ github.sha }} |
| 38 | + run: | |
| 39 | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./captioning-service |
| 40 | + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |
| 41 | + echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" |
| 42 | +
|
| 43 | + - name: Update Amazon ECS service |
| 44 | + run: | |
| 45 | + aws ecs update-service --cluster ai-services-cluster --service captioning-service --force-new-deployment |
| 46 | +
|
| 47 | + deploy-classifying: |
| 48 | + name: Deploy Classifying Service |
| 49 | + runs-on: ubuntu-latest |
| 50 | + if: "contains(github.event.head_commit.message, '[force deploy]') || contains(join(github.event.commits.*.modified), 'classifying-service/') || contains(join(github.event.commits.*.added), 'classifying-service/')" |
| 51 | + |
| 52 | + steps: |
| 53 | + - name: Checkout |
| 54 | + uses: actions/checkout@v3 |
| 55 | + |
| 56 | + - name: Configure AWS credentials |
| 57 | + uses: aws-actions/configure-aws-credentials@v2 |
| 58 | + with: |
| 59 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 60 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 61 | + aws-region: ${{ env.AWS_REGION }} |
| 62 | + |
| 63 | + - name: Login to Amazon ECR |
| 64 | + id: login-ecr |
| 65 | + uses: aws-actions/amazon-ecr-login@v1 |
| 66 | + |
| 67 | + - name: Build, tag, and push image to Amazon ECR |
| 68 | + id: build-image |
| 69 | + env: |
| 70 | + ECR_REPOSITORY: classifying-service |
| 71 | + IMAGE_TAG: ${{ github.sha }} |
| 72 | + run: | |
| 73 | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./classifying-service |
| 74 | + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |
| 75 | + echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" |
| 76 | +
|
| 77 | + - name: Update Amazon ECS service |
| 78 | + run: | |
| 79 | + aws ecs update-service --cluster ai-services-cluster --service classifying-service --force-new-deployment |
| 80 | +
|
| 81 | + deploy-masking: |
| 82 | + name: Deploy Masking Service |
| 83 | + runs-on: ubuntu-latest |
| 84 | + if: "contains(github.event.head_commit.message, '[force deploy]') || contains(join(github.event.commits.*.modified), 'masking-service/') || contains(join(github.event.commits.*.added), 'masking-service/')" |
| 85 | + |
| 86 | + steps: |
| 87 | + - name: Checkout |
| 88 | + uses: actions/checkout@v3 |
| 89 | + |
| 90 | + - name: Configure AWS credentials |
| 91 | + uses: aws-actions/configure-aws-credentials@v2 |
| 92 | + with: |
| 93 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 94 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 95 | + aws-region: ${{ env.AWS_REGION }} |
| 96 | + |
| 97 | + - name: Login to Amazon ECR |
| 98 | + id: login-ecr |
| 99 | + uses: aws-actions/amazon-ecr-login@v1 |
| 100 | + |
| 101 | + - name: Build, tag, and push image to Amazon ECR |
| 102 | + id: build-image |
| 103 | + env: |
| 104 | + ECR_REPOSITORY: masking-service |
| 105 | + IMAGE_TAG: ${{ github.sha }} |
| 106 | + run: | |
| 107 | + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./masking-service |
| 108 | + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG |
| 109 | + echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" |
| 110 | +
|
| 111 | + - name: Update Amazon ECS service |
| 112 | + run: | |
| 113 | + aws ecs update-service --cluster ai-services-cluster --service masking-service --force-new-deployment |
0 commit comments