From ea0acaff1506bfe1274a369837b408998ba8d071 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 1 Apr 2024 12:05:11 -0400 Subject: [PATCH 1/4] Create the release workflow Signed-off-by: Kevin Ullyott --- .github/workflows/release.yml | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..fd1bc02d7 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,67 @@ +name: Deploy to Production Environment + +on: + release: + types: [released] + +env: + AWS_REGION: "us-west-2" + ECR_REPOSITORY: "aidingapp" + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-22.04 + environment: production + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + ref: ${{ github.head_ref }} + token: ${{ secrets.PAT }} + + - name: Configure AWS credentials + # SHA of release v4.0.2 + uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 + with: + aws-access-key-id: ${{ secrets.PROD_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.PROD_AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + # SHA of release v2.0.1 + uses: aws-actions/amazon-ecr-login@062b18b96a7aff071d4dc91bc00c4c1a7945b076 + + - 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 }} + 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 deploy --platform linux/amd64 --build-arg USER_ID=9999 --build-arg GROUP_ID=9999 . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT + + - name: Fill in the new image ID in the Amazon ECS task definition + id: task-def + # SHA of release v1.2.0 + uses: aws-actions/amazon-ecs-render-task-definition@4225e0b507142a2e432b018bc3ccb728559b437a + with: + task-definition: "docker/devops/ecs/aidingapp/aidingapp-prod-task-definition.json" + container-name: "app" + image: ${{ steps.build-image.outputs.image }} + + - name: Deploy Amazon ECS task definition + # SHA of release v1.4.11 + uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + service: "aidingapp-prod-service" + cluster: "aidingapp-prod" + wait-for-service-stability: true \ No newline at end of file From 71764cb90d681651f8fbeaff8e6513a7a8f2a616 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 1 Apr 2024 12:09:03 -0400 Subject: [PATCH 2/4] Improve the nginx check Signed-off-by: Kevin Ullyott --- docker/s6-overlay/s6-rc.d/nginx/data/check | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docker/s6-overlay/s6-rc.d/nginx/data/check b/docker/s6-overlay/s6-rc.d/nginx/data/check index 38a69a4f5..caf4cfa8f 100755 --- a/docker/s6-overlay/s6-rc.d/nginx/data/check +++ b/docker/s6-overlay/s6-rc.d/nginx/data/check @@ -1,8 +1,7 @@ #!/command/with-contenv bash -response=$(curl -I --location --insecure --silent http://localhost | awk '/^HTTP/{print $2}') +response=$(curl -s -o /dev/null -w "%{http_code}" -L --insecure http://localhost) -if [[ $response == "302 -200" ]] || [[ $response == "302" ]]; then +if [[ $response == "200" ]]; then exit 0 else echo "❌ There seems to be a failure in checking the web server. Here's the response:" From 7d1bb87cb583c2feacd2bf78402948af3e6cf8ce Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Mon, 1 Apr 2024 12:10:20 -0400 Subject: [PATCH 3/4] Devops updates Signed-off-by: Kevin Ullyott --- docker/devops | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/devops b/docker/devops index aa6e3d1e0..520c66deb 160000 --- a/docker/devops +++ b/docker/devops @@ -1 +1 @@ -Subproject commit aa6e3d1e08a7543bd07c63e2ac272e7bcfc5ffd5 +Subproject commit 520c66deb104ad2d7fcc1c76db9fcd2c6a686c4b From 8db3587d14de9cb8db0075b0f43d35d611ab0428 Mon Sep 17 00:00:00 2001 From: Kevin Ullyott Date: Tue, 2 Apr 2024 14:37:43 -0400 Subject: [PATCH 4/4] Update to merge commit hash for devops Signed-off-by: Kevin Ullyott --- docker/devops | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/devops b/docker/devops index 520c66deb..8eb77297d 160000 --- a/docker/devops +++ b/docker/devops @@ -1 +1 @@ -Subproject commit 520c66deb104ad2d7fcc1c76db9fcd2c6a686c4b +Subproject commit 8eb77297decd155db6adc8a43d2f23866d4f04e1