From 7ab812dadf04cc099d5d130842f8eb29bea98812 Mon Sep 17 00:00:00 2001 From: Sheetal Date: Fri, 7 Jun 2024 12:21:24 +0530 Subject: [PATCH] dev cicd workflow file implemented with taskdef script --- .github/workflows/dev-afj.yml | 24 +++++++++---------- ...nt-service.json => dev-credo-service.json} | 7 +----- 2 files changed, 12 insertions(+), 19 deletions(-) rename taskdef/{agent-service.json => dev-credo-service.json} (90%) diff --git a/.github/workflows/dev-afj.yml b/.github/workflows/dev-afj.yml index 6c776aae..929c24f2 100644 --- a/.github/workflows/dev-afj.yml +++ b/.github/workflows/dev-afj.yml @@ -1,20 +1,18 @@ -name: Build and deploy Node.js app to ECSsdc +name: Build and deploy CREDO DEV to ECS on: push: branches: - pipeline-implementation - paths: - - 'apps/agent-service/**' - workflow_dispatch: + env: - ECR_IMAGE_TAG: "AGENT_V_${{ github.run_number }}" + ECR_IMAGE_TAG: "AFJ_V_${{ github.run_number }}" ECR_REPOSITORY: "dev-services" AWS_REGION: "ap-southeast-1" - CLUSTER: "DEV-NGOTAG-CLUSTER" + CLUSTER: "DEV_AFJ_CLUSTER" jobs: build: @@ -47,7 +45,7 @@ jobs: env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: dev-services - IMAGE_TAG: "AGENT_V_${{ github.run_number }}" + IMAGE_TAG: "AFJ_V_${{ github.run_number }}" run: | docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG @@ -57,7 +55,7 @@ jobs: run: | echo "ECR_REGISTRY=${{ steps.login-ecr.outputs.registry }}" >> $GITHUB_ENV echo "ECR_REPOSITORY=dev-services" >> $GITHUB_ENV - echo "IMAGE_TAG=AGENT_V_${{ github.run_number }}" >> $GITHUB_ENV + echo "IMAGE_TAG=AFJ_V_${{ github.run_number }}" >> $GITHUB_ENV - name: Print environment variables run: | @@ -72,17 +70,17 @@ jobs: - name: Replace executionRoleArn in task definition run: | - sed -i "s#\"executionRoleArn\": \"arn:aws:iam::.*:role/ecsTaskExecutionRole\"#\"executionRoleArn\": \"arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ecsTaskExecutionRole\"#" taskdef/credo-service.json + sed -i "s#\"executionRoleArn\": \"arn:aws:iam::.*:role/ecsTaskExecutionRole\"#\"executionRoleArn\": \"arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/ecsTaskExecutionRole\"#" taskdef/dev-credo-service.json - name: Update Task Definition and service run: | - FAMILY=$(sed -n 's/.*"family": "\(.*\)",/\1/p' taskdef/credo-service.json) - NAME=$(sed -n 's/.*"name": "\(.*\)",/\1/p' taskdef/credo-service.json) - SERVICE_NAME="${NAME}-service" + FAMILY=$(sed -n 's/.*"family": "\(.*\)",/\1/p' taskdef/dev-credo-service.json) + NAME=$(sed -n 's/.*"name": "\(.*\)",/\1/p' taskdef/dev-credo-service.json) + SERVICE_NAME="AFJ-Platform-Admin" echo "SERVICE_NAME: $SERVICE_NAME" # Replace placeholders in the JSON file - sed -e "s;%BUILD_NUMBER%;${{ github.run_number }};g" -e "s;%REPOSITORY_URI%;${REPOSITORY_URI};g" taskdef/credo-service.json > ${GITHUB_WORKSPACE}/${NAME}-v_${{ github.run_number }}.json + sed -e "s;%BUILD_NUMBER%;${{ github.run_number }};g" -e "s;%REPOSITORY_URI%;${REPOSITORY_URI};g" taskdef/dev-credo-service.json > ${GITHUB_WORKSPACE}/${NAME}-v_${{ github.run_number }}.json # Debug: Print the content of the modified JSON file cat ${GITHUB_WORKSPACE}/${NAME}-v_${{ github.run_number }}.json diff --git a/taskdef/agent-service.json b/taskdef/dev-credo-service.json similarity index 90% rename from taskdef/agent-service.json rename to taskdef/dev-credo-service.json index fc7228ac..214c9d6f 100644 --- a/taskdef/agent-service.json +++ b/taskdef/dev-credo-service.json @@ -26,12 +26,7 @@ "/config/685df587-7cf5-46cf-873c-502719ac5c35_Platform-admin.json" ], "environment": [], - "environmentFiles": [ - { - "value": "arn:aws:s3:::env-qabucket/.env", - "type": "s3" - } - ], + "environmentFiles": [], "mountPoints": [ { "sourceVolume": "AGENT-CONFIG",