Skip to content

Added new revision

Added new revision #11

Workflow file for this run

name: Reancare ECS Deployment
on:
push:
branches:
- develop-inflection
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install AWS CLI
run: |
sudo apt-get update
sudo apt-get install -y awscli
- name: Install dependencies
run: npm install
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-south-1
- name: Login to Amazon ECR
run: aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin 443751504066.dkr.ecr.ap-south-1.amazonaws.com
- name: Build Docker image
run: |
docker build -t 443751504066.dkr.ecr.ap-south-1.amazonaws.com/reancare:${{ github.sha }} .
docker push 443751504066.dkr.ecr.ap-south-1.amazonaws.com/reancare:${{ github.sha }}
- name: Get the latest revision of ECS task definition
id: get-latest-revision
run: |
latest_revision=$(aws ecs describe-task-definition --task-definition reancare-service --query 'taskDefinition.revision' --output text)
echo "Latest revision: $latest_revision"
echo "::set-output name=revision::$latest_revision"
- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition reancare-service:${{ steps.get-latest-revision.outputs.revision }} \
--query taskDefinition > task-definition.json
cat task-definition.json
- name: Update container image in task definition
run: |
jq '.containerDefinitions[0].image="443751504066.dkr.ecr.ap-south-1.amazonaws.com/reancare:${{ github.sha }}"' task-definition.json > new-task-definition.json
jq 'del(.taskDefinitionArn, .revision)' new-task-definition.json > modified-task-definition.json
cat modified-task-definition.json
mv modified-task-definition.json new-task-definition.json
cat new-task-definition.json
# - name: New image ID in the Amazon ECS task definition
# id: task-def
# uses: aws-actions/amazon-ecs-render-task-definition@v1
# with:
# task-definition: task-definition.json
# container-name: reancare-container
# image: 443751504066.dkr.ecr.ap-south-1.amazonaws.com/reancare:${{ github.sha }}
- name: Create a new revision of ECS task definition
id: create-new-revision
run: |
new_revision=$(aws ecs register-task-definition --cli-input-json file://new-task-definition.json --query 'taskDefinition.revision' --output text)
echo "New revision created: $new_revision"
echo "::set-output name=new-revision::$new_revision"
- name: Task Definition Variable
id: taskdefintionvar
shell: bash
run: |
echo "task_definition_arn=$(aws ecs describe-task-definition --task-definition reancare-service | jq -r '.taskDefinition.taskDefinitionArn')" >> $GITHUB_OUTPUT
- name: Deploy to ECS
run: |
aws ecs update-service --cluster reancare-cluster --service rean-backend --task-definition reancare-service:${{ steps.create-new-revision.outputs.new-revision }} --force-new-deployment