Skip to content

Commit

Permalink
dev cicd workflow file implemented with taskdef script
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheetal-ayanworks committed Jun 7, 2024
1 parent 22f403e commit 7ab812d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
24 changes: 11 additions & 13 deletions .github/workflows/dev-afj.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7ab812d

Please sign in to comment.