Skip to content

Commit

Permalink
activating migration
Browse files Browse the repository at this point in the history
  • Loading branch information
aweiland committed Jul 2, 2024
1 parent 8f63650 commit 67be608
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/run_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,23 @@ jobs:
deploy_to_dev:
needs: build_job
if: ${{ github.event.pull_request.merged }}
#if: ${{ github.event.pull_request.merged }}
uses: ./.github/workflows/run_deploy_dev.yaml
with:
COMMIT_HASH: ${{ github.sha }}
IMAGE_PREFIX: ${{ github.ref_name }}
IMAGE_NAME: ${{needs.build_job.outputs.IMAGE_NAME}}

deploy_to_uat:
needs: build_job
uses: ChildMindInstitute/mindlogger-backend-refactor/.github/workflows/run_deploy_uat.yaml@develop
with:
COMMIT_HASH: ${{ github.sha }}
IMAGE_PREFIX: ${{ github.ref_name }}

deploy_to_test:
needs: build_job
uses: ChildMindInstitute/mindlogger-backend-refactor/.github/workflows/run_deploy_test.yaml@develop
with:
COMMIT_HASH: ${{ github.sha }}
IMAGE_PREFIX: ${{ github.ref_name }}
# deploy_to_uat:
# needs: build_job
# uses: ChildMindInstitute/mindlogger-backend-refactor/.github/workflows/run_deploy_uat.yaml@develop
# with:
# COMMIT_HASH: ${{ github.sha }}
# IMAGE_PREFIX: ${{ github.ref_name }}
#
# deploy_to_test:
# needs: build_job
# uses: ChildMindInstitute/mindlogger-backend-refactor/.github/workflows/run_deploy_test.yaml@develop
# with:
# COMMIT_HASH: ${{ github.sha }}
# IMAGE_PREFIX: ${{ github.ref_name }}
25 changes: 11 additions & 14 deletions .github/workflows/run_deploy_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ permissions:
contents: read
issues: write

jobs:
env:
AWS_REGION: us-east-1
ECS_CLUSTER_NAME: cmiml-dev
IMAGE_NAME: ${{ inputs.IMAGE_NAME }}

jobs:
run_migration:
runs-on: ubuntu-latest
env:
TASK_DEFINITION: migration
ECS_CLUSTER_NAME: cmiml-dev
ECS_SERVICE_NAME: migration
AWS_REGION: us-east-1
IMAGE_NAME: ${{ inputs.IMAGE_NAME }}

steps:

steps:
- name: echo IMAGE_NAME
run: |
echo $IMAGE_NAME
Expand All @@ -51,7 +51,7 @@ jobs:
with:
task-definition: task-definition.json
container-name: mind_logger
image: ${{ env.IMAGE_NAME }}
image: ${{ inputs.IMAGE_NAME }}

- name: Run migration container
id: run-task
Expand All @@ -71,15 +71,12 @@ jobs:
needs: run_migration
env:
TASK_FAMILY_PREFIX: backend
ECS_CLUSTER_NAME: cmiml-dev
ECS_SERVICE_NAME: backend
ECR_REPO: 917902836630.dkr.ecr.us-east-1.amazonaws.com
IMAGE_PREFIX: ${{ inputs.COMMIT_HASH }}
COMMIT_HASH: ${{ inputs.IMAGE_PREFIX }}
AWS_REGION : "us-east-1"

steps:

steps:
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand All @@ -89,9 +86,9 @@ jobs:

- name: change image and register task definitions
run: |
NEW_IMAGE=${IMAGE_PREFIX/\//-}-$(echo $COMMIT_HASH | cut -c1-5)
# NEW_IMAGE=${IMAGE_PREFIX/\//-}-$(echo $COMMIT_HASH | cut -c1-5)
for app in api worker scheduler; do
export NEW_TASK_DEFINITION=$(aws ecs describe-task-definition --task-definition ${TASK_FAMILY_PREFIX}_${app} --region ${AWS_REGION} | jq --arg IMAGE "$ECR_REPO:$NEW_IMAGE" '.taskDefinition | .containerDefinitions[0].image = $IMAGE | del(.taskDefinitionArn) | del(.revision) | del(.status) | del(.requiresAttributes) | del(.compatibilities) | del(.registeredAt) | del(.registeredBy)')
export NEW_TASK_DEFINITION=$(aws ecs describe-task-definition --task-definition ${TASK_FAMILY_PREFIX}_${app} --region ${AWS_REGION} | jq --arg IMAGE "$IMAGE_NAME" '.taskDefinition | .containerDefinitions[0].image = $IMAGE | del(.taskDefinitionArn) | del(.revision) | del(.status) | del(.requiresAttributes) | del(.compatibilities) | del(.registeredAt) | del(.registeredBy)')
aws ecs register-task-definition --region ${AWS_REGION} --cli-input-json "$NEW_TASK_DEFINITION"
done

Expand All @@ -101,7 +98,7 @@ jobs:
aws ecs update-service --cluster ${ECS_CLUSTER_NAME} --service ${ECS_SERVICE_NAME}-${app} --task-definition ${TASK_FAMILY_PREFIX}_${app}
done
#this step is separate because api sarvice and task definition names are different, need to be changed
#this step is separate because api service and task definition names are different, need to be changed
aws ecs update-service --cluster ${ECS_CLUSTER_NAME} --service ${ECS_SERVICE_NAME} --task-definition ${TASK_FAMILY_PREFIX}_api
Expand Down

0 comments on commit 67be608

Please sign in to comment.