From 62f13bfa75651d6d50aa7af0d104420dd221809f Mon Sep 17 00:00:00 2001 From: rf-opssupport <84499879+rf-opssupport@users.noreply.github.com> Date: Wed, 16 Oct 2024 18:39:52 +0530 Subject: [PATCH 1/9] Update aha-uat-ci-cd.yml --- .github/workflows/aha-uat-ci-cd.yml | 41 ++++++++++++++++------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/.github/workflows/aha-uat-ci-cd.yml b/.github/workflows/aha-uat-ci-cd.yml index 1610ca8..370b9b6 100644 --- a/.github/workflows/aha-uat-ci-cd.yml +++ b/.github/workflows/aha-uat-ci-cd.yml @@ -13,15 +13,30 @@ on: workflow_dispatch: inputs: Tag_name: - description: Tag name of your release(please include "v" if needed) + description: Tag name of your release(please include "v") required: true jobs: - +# CodeScan-ESLint: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout Code +# uses: actions/checkout@v3 +# with: +# fetch-depth: 0 + +# - name: Lint Code Base +# uses: github/super-linter@v4 +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# LINTER_RULES_PATH: / +# TYPESCRIPT_ES_CONFIG_FILE: .eslintrc.json +# VALIDATE_TYPESCRIPT_ES: true + + Github-ECR-Tag-Check: runs-on: ubuntu-latest - steps: - name: check tag uses: mukunku/tag-exists-action@v1.2.0 @@ -37,7 +52,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }} with: tag: ${{ github.event.inputs.Tag_name }} - repo: REAN-Foundation/user-analytics-prod + repo: REAN-Foundation/user-analytics - name: Configure AWS credentials if: ${{ steps.checkTag.outputs.exists == 'true' }} @@ -63,26 +78,16 @@ jobs: release_name: ${{ steps.result_release.outputs.tag_name }} release_id: ${{ steps.result_release.outputs.id }} - - Deploy-ECS: needs: Github-ECR-Tag-Check environment: aha-uat runs-on: ubuntu-latest steps: + - name: Checkout uses: actions/checkout@v3 - - - name: Get release - id: result_release - uses: cardinalby/git-get-release-action@v1 - env: - GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }} - with: - tag: ${{ github.event.inputs.Tag_name }} - repo: REAN-Foundation/user-analytics-prod - + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: @@ -118,8 +123,6 @@ jobs: container-name: default image: public.ecr.aws/i9y2d4u3/user-analytics-prod:${{ needs.Github-ECR-Tag-Check.outputs.release_name }}_${{ needs.Github-ECR-Tag-Check.outputs.release_id }} - - - name: Deploy Amazon ECS task definition uses: aws-actions/amazon-ecs-deploy-task-definition@v1 with: @@ -141,5 +144,5 @@ jobs: with: url: 'https://reanfoundation.duplocloud.net/subscriptions/${{ secrets.DUPLO_ID }}/UpdateEcsService' method: 'POST' - data: '{"TaskDefinition":${{ steps.taskdefintionvar.outputs.task_definition_arn }},"Name": "${{ secrets.SERVICE_NAME }}","Replicas":1, "HealthCheckGracePeriodSeconds": 1200,"DnsPrfx": ""}' + data: '{"TaskDefinition":${{ steps.taskdefintionvar.outputs.task_definition_arn }},"Name": "${{ secrets.SERVICE_NAME }}","Replicas":1, "HealthCheckGracePeriodSeconds": 1200, "DnsPrfx": ""}' bearerToken: ${{ secrets.DUPLOCLOUD_TOKEN }} From 7d59dac98322f5ce83246125c2bde74a97725762 Mon Sep 17 00:00:00 2001 From: rf-opssupport <84499879+rf-opssupport@users.noreply.github.com> Date: Wed, 16 Oct 2024 20:18:21 +0530 Subject: [PATCH 2/9] Update aha-prod-ci-cd.yml --- .github/workflows/aha-prod-ci-cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/aha-prod-ci-cd.yml b/.github/workflows/aha-prod-ci-cd.yml index 55cf90c..d77c78f 100644 --- a/.github/workflows/aha-prod-ci-cd.yml +++ b/.github/workflows/aha-prod-ci-cd.yml @@ -37,7 +37,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }} with: tag: ${{ github.event.inputs.Tag_name }} - repo: REAN-Foundation/user-analytics-prod + repo: REAN-Foundation/user-analytics - name: Configure AWS credentials if: ${{ steps.checkTag.outputs.exists == 'true' }} @@ -81,7 +81,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }} with: tag: ${{ github.event.inputs.Tag_name }} - repo: REAN-Foundation/user-analytics-prod + repo: REAN-Foundation/user-analytics - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 From 23eb7df6634d200c2a412cb985a99045e2a10910 Mon Sep 17 00:00:00 2001 From: rf-opssupport <84499879+rf-opssupport@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:29:29 +0530 Subject: [PATCH 3/9] Update prod-ci-cd.yml --- .github/workflows/prod-ci-cd.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/prod-ci-cd.yml b/.github/workflows/prod-ci-cd.yml index 42b5fc5..718030f 100644 --- a/.github/workflows/prod-ci-cd.yml +++ b/.github/workflows/prod-ci-cd.yml @@ -4,7 +4,6 @@ # To use this workflow, you will need to set up a .github/labeler.yml # file with configuration. For more information, see: # https://github.com/actions/labeler - name: PROD-CI-CD # Controls when the workflow will run From cc514de8675647187b32b5e092dd38ea70ef6f33 Mon Sep 17 00:00:00 2001 From: rf-opssupport <84499879+rf-opssupport@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:29:54 +0530 Subject: [PATCH 4/9] Update prod-ci-cd.yml --- .github/workflows/prod-ci-cd.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/prod-ci-cd.yml b/.github/workflows/prod-ci-cd.yml index 718030f..21fa7a4 100644 --- a/.github/workflows/prod-ci-cd.yml +++ b/.github/workflows/prod-ci-cd.yml @@ -60,9 +60,6 @@ jobs: key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- - - - name: Copy env file - run: aws s3 cp s3://${{ secrets.ENV_FILE_BUCKET_PATH }}/.env ./.env - name: Build and push id: docker_build From 6e717a0d18d8d0c7aa98190a6d7feaeeff877b72 Mon Sep 17 00:00:00 2001 From: rf-opssupport <84499879+rf-opssupport@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:50:00 +0530 Subject: [PATCH 5/9] Delete Dockerfile --- Dockerfile | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 39461fe..0000000 --- a/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -FROM python:3.10 - -# Install dependencies including pandoc -RUN apt-get update && \ - apt-get install -y --no-install-recommends \ - pandoc \ - libexpat1 \ - texlive-xetex \ - texlive-fonts-recommended \ - texlive-plain-generic \ - texlive-latex-extra \ - && apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -WORKDIR /app -RUN python -m venv venv -RUN . venv/bin/activate -RUN pip install --upgrade pip -RUN pip install setuptools wheel -COPY requirements.txt /app/ -RUN pip install --no-cache-dir -r requirements.txt -COPY . /app -EXPOSE 3000 -CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "3000"] From a9addd7a089339465e4181579144cf5ad22f6793 Mon Sep 17 00:00:00 2001 From: rf-opssupport <84499879+rf-opssupport@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:50:50 +0530 Subject: [PATCH 6/9] Add files via upload --- Dockerfile.txt | 33 +++++++++++++++++++++++++++++++++ entrypoint.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 Dockerfile.txt create mode 100644 entrypoint.sh diff --git a/Dockerfile.txt b/Dockerfile.txt new file mode 100644 index 0000000..d0dd708 --- /dev/null +++ b/Dockerfile.txt @@ -0,0 +1,33 @@ +FROM python:3.10 +ADD . /app + +# Install dependencies including pandoc and AWS CLI +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + pandoc \ + libexpat1 \ + texlive-xetex \ + texlive-fonts-recommended \ + texlive-plain-generic \ + texlive-latex-extra \ + python3 \ + python3-pip \ + && pip3 install --upgrade pip \ + && pip3 install awscli \ + && apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /app +RUN python -m venv venv +RUN . venv/bin/activate +RUN pip install --upgrade pip +RUN pip install setuptools wheel +RUN pip install --no-cache-dir -r requirements.txt + +# Make sure entrypoint.sh is executable +RUN chmod +x /app/entrypoint.sh + +EXPOSE 3000 + +# Set the entrypoint +ENTRYPOINT ["/bin/bash", "-c", "/app/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..6e797e1 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Exit immediately if a command exits with a non-zero status +set -e + +# Function to handle errors +handle_error() { + echo "Error on line $1" + exit 1 +} + +# Trap errors and call the error handler +trap 'handle_error $LINENO' ERR + +# Add config/creds copying here.. +if ! aws s3 cp s3://$S3_CONFIG_BUCKET/$S3_CONFIG_PATH/env.config /app/.env; then + echo "Failed to copy env.config from S3." + exit 1 +fi + +# Change to the application directory +cd /app + +# Start the Uvicorn server +if ! uvicorn main:app --host 0.0.0.0 --port 3000; then + echo "Failed to start Uvicorn server." + exit 1 +fi From c6512077dc2b54de8961bbd77b7cd6fd4779f055 Mon Sep 17 00:00:00 2001 From: rf-opssupport <84499879+rf-opssupport@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:56:11 +0530 Subject: [PATCH 7/9] Update prod-ci-cd.yml --- .github/workflows/prod-ci-cd.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/prod-ci-cd.yml b/.github/workflows/prod-ci-cd.yml index 21fa7a4..2c57a8b 100644 --- a/.github/workflows/prod-ci-cd.yml +++ b/.github/workflows/prod-ci-cd.yml @@ -6,6 +6,7 @@ # https://github.com/actions/labeler name: PROD-CI-CD + # Controls when the workflow will run on: # Triggers the workflow on push events but only for the develop branch From 75f5167b4f643c56666f581a8c853754298bda48 Mon Sep 17 00:00:00 2001 From: rf-opssupport <84499879+rf-opssupport@users.noreply.github.com> Date: Wed, 23 Oct 2024 23:58:18 +0530 Subject: [PATCH 8/9] Rename Dockerfile.txt to Dockerfile --- Dockerfile.txt => Dockerfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Dockerfile.txt => Dockerfile (100%) diff --git a/Dockerfile.txt b/Dockerfile similarity index 100% rename from Dockerfile.txt rename to Dockerfile From 8e22561352d4bc6f3e40333f5f4bc1b9c8aee8a1 Mon Sep 17 00:00:00 2001 From: Priyanka-Inflectionzone Date: Mon, 20 Jan 2025 12:14:01 +0530 Subject: [PATCH 9/9] Modified CI/CD Workflow Files --- .github/workflows/aha-prod-ci-cd.yml | 20 ++++++++++---------- .github/workflows/aha-uat-ci-cd.yml | 20 ++++++++++---------- .github/workflows/dev-ci-cd.yml | 2 +- .github/workflows/prod-ci-cd.yml | 10 +++++----- .github/workflows/uat-ci-cd.yml | 8 ++++---- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/aha-prod-ci-cd.yml b/.github/workflows/aha-prod-ci-cd.yml index d77c78f..0110dea 100644 --- a/.github/workflows/aha-prod-ci-cd.yml +++ b/.github/workflows/aha-prod-ci-cd.yml @@ -21,14 +21,14 @@ jobs: Github-ECR-Tag-Check: runs-on: ubuntu-latest - + steps: - name: check tag uses: mukunku/tag-exists-action@v1.2.0 id: checkTag - with: + with: tag: ${{ github.event.inputs.Tag_name }} - + - name: Get release if: ${{ steps.checkTag.outputs.exists == 'true' }} id: result_release @@ -38,7 +38,7 @@ jobs: with: tag: ${{ github.event.inputs.Tag_name }} repo: REAN-Foundation/user-analytics - + - name: Configure AWS credentials if: ${{ steps.checkTag.outputs.exists == 'true' }} uses: aws-actions/configure-aws-credentials@v1 @@ -46,19 +46,19 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ secrets.AWS_REGION }} - + - name: Get ECR Image Tag if: ${{ steps.checkTag.outputs.exists == 'true' }} id: imageidvar run: | image_tag+=${{ steps.result_release.outputs.tag_name }} && image_tag+=_ && image_tag+=${{ steps.result_release.outputs.id }} echo "imagetag_value=$(aws ecr-public describe-image-tags --repository-name user-analytics-prod --region us-east-1 --query "imageTagDetails[?imageTag=='$image_tag'].imageTag" --output text)" >> $GITHUB_OUTPUT - + - name: ECR Image and Github Tag Check run: | if [[ ${{ steps.checkTag.outputs.exists }} == 'false' ]]; then exit 1; fi if [[ -z "${{ steps.imageidvar.outputs.imagetag_value }}" ]]; then exit 1; fi - + outputs: release_name: ${{ steps.result_release.outputs.tag_name }} release_id: ${{ steps.result_release.outputs.id }} @@ -73,7 +73,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - + - name: Get release id: result_release uses: cardinalby/git-get-release-action@v1 @@ -82,7 +82,7 @@ jobs: with: tag: ${{ github.event.inputs.Tag_name }} repo: REAN-Foundation/user-analytics - + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: @@ -119,7 +119,7 @@ jobs: image: public.ecr.aws/i9y2d4u3/user-analytics-prod:${{ needs.Github-ECR-Tag-Check.outputs.release_name }}_${{ needs.Github-ECR-Tag-Check.outputs.release_id }} - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + uses: aws-actions/amazon-ecs-deploy-task-definition@v2 with: task-definition: ${{ steps.task-def.outputs.task-definition }} wait-for-service-stability: true diff --git a/.github/workflows/aha-uat-ci-cd.yml b/.github/workflows/aha-uat-ci-cd.yml index 370b9b6..1217f66 100644 --- a/.github/workflows/aha-uat-ci-cd.yml +++ b/.github/workflows/aha-uat-ci-cd.yml @@ -33,17 +33,17 @@ jobs: # LINTER_RULES_PATH: / # TYPESCRIPT_ES_CONFIG_FILE: .eslintrc.json # VALIDATE_TYPESCRIPT_ES: true - - + + Github-ECR-Tag-Check: runs-on: ubuntu-latest steps: - name: check tag uses: mukunku/tag-exists-action@v1.2.0 id: checkTag - with: + with: tag: ${{ github.event.inputs.Tag_name }} - + - name: Get release if: ${{ steps.checkTag.outputs.exists == 'true' }} id: result_release @@ -53,7 +53,7 @@ jobs: with: tag: ${{ github.event.inputs.Tag_name }} repo: REAN-Foundation/user-analytics - + - name: Configure AWS credentials if: ${{ steps.checkTag.outputs.exists == 'true' }} uses: aws-actions/configure-aws-credentials@v1 @@ -61,19 +61,19 @@ jobs: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ secrets.AWS_REGION }} - + - name: Get ECR Image Tag if: ${{ steps.checkTag.outputs.exists == 'true' }} id: imageidvar run: | image_tag+=${{ steps.result_release.outputs.tag_name }} && image_tag+=_ && image_tag+=${{ steps.result_release.outputs.id }} echo "imagetag_value=$(aws ecr-public describe-image-tags --repository-name user-analytics-prod --region us-east-1 --query "imageTagDetails[?imageTag=='$image_tag'].imageTag" --output text)" >> $GITHUB_OUTPUT - + - name: ECR Image and Github Tag Check run: | if [[ ${{ steps.checkTag.outputs.exists }} == 'false' ]]; then exit 1; fi if [[ -z "${{ steps.imageidvar.outputs.imagetag_value }}" ]]; then exit 1; fi - + outputs: release_name: ${{ steps.result_release.outputs.tag_name }} release_id: ${{ steps.result_release.outputs.id }} @@ -87,7 +87,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 - + - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 with: @@ -124,7 +124,7 @@ jobs: image: public.ecr.aws/i9y2d4u3/user-analytics-prod:${{ needs.Github-ECR-Tag-Check.outputs.release_name }}_${{ needs.Github-ECR-Tag-Check.outputs.release_id }} - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + uses: aws-actions/amazon-ecs-deploy-task-definition@v2 with: task-definition: ${{ steps.task-def.outputs.task-definition }} wait-for-service-stability: true diff --git a/.github/workflows/dev-ci-cd.yml b/.github/workflows/dev-ci-cd.yml index fd6d074..acf6cae 100644 --- a/.github/workflows/dev-ci-cd.yml +++ b/.github/workflows/dev-ci-cd.yml @@ -92,7 +92,7 @@ jobs: image: ${{ steps.login-ecr.outputs.registry }}/user-analytics-dev-uat:${{ steps.vars.outputs.branch }}_${{ steps.vars.outputs.sha_short }} - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + uses: aws-actions/amazon-ecs-deploy-task-definition@v2 with: task-definition: ${{ steps.task-def.outputs.task-definition }} wait-for-service-stability: true diff --git a/.github/workflows/prod-ci-cd.yml b/.github/workflows/prod-ci-cd.yml index 2c57a8b..882d75e 100644 --- a/.github/workflows/prod-ci-cd.yml +++ b/.github/workflows/prod-ci-cd.yml @@ -14,7 +14,7 @@ on: branches: [main] jobs: - + Publish-Release: runs-on: ubuntu-latest steps: @@ -25,11 +25,11 @@ jobs: publish : true env: GITHUB_TOKEN: ${{ secrets.PAT_GITHUB }} - + outputs: release_id: ${{ steps.new_publish.outputs.id }} release_name: ${{ steps.new_publish.outputs.tag_name }} - + Deploy-ECS: needs: Publish-Release @@ -61,7 +61,7 @@ jobs: key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- - + - name: Build and push id: docker_build uses: docker/build-push-action@v3 @@ -91,7 +91,7 @@ jobs: image: public.ecr.aws/i9y2d4u3/user-analytics-prod:${{ needs.Publish-Release.outputs.release_name }}_${{ needs.Publish-Release.outputs.release_id }} - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + uses: aws-actions/amazon-ecs-deploy-task-definition@v2 with: task-definition: ${{ steps.task-def.outputs.task-definition }} wait-for-service-stability: true diff --git a/.github/workflows/uat-ci-cd.yml b/.github/workflows/uat-ci-cd.yml index f47fc50..3820616 100644 --- a/.github/workflows/uat-ci-cd.yml +++ b/.github/workflows/uat-ci-cd.yml @@ -32,7 +32,7 @@ jobs: VALIDATE_TYPESCRIPT_ES: true VALIDATE_ALL_CODEBASE: false DEFAULT_BRANCH: main - + Label_Checks: runs-on: ubuntu-latest steps: @@ -40,7 +40,7 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - + - name: Check labels if: ${{ github.event_name == 'pull_request' }} uses: docker://agilepathway/pull-request-label-checker:latest @@ -97,7 +97,7 @@ jobs: id: docker_build uses: docker/build-push-action@v3 with: - context: ./ + context: ./ file: ./Dockerfile builder: ${{ steps.buildx.outputs.name }} push: true @@ -122,7 +122,7 @@ jobs: image: ${{ steps.login-ecr.outputs.registry }}/user-analytics-dev-uat:${{ steps.vars.outputs.branch }}_${{ steps.vars.outputs.sha_short }} - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + uses: aws-actions/amazon-ecs-deploy-task-definition@v2 with: task-definition: ${{ steps.task-def.outputs.task-definition }} wait-for-service-stability: true