Skip to content

Update app.js

Update app.js #17

Workflow file for this run

name: CICD
on:
push:
branches: [prodution]
jobs:
build-and-deploy:
runs-on: [ubuntu-latest]
steps:
- name: Checkout source
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: "us-east-1"
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: "true"
- name: Notify Build Failure
if: failure() && steps.build-push.conclusion == 'failure'
run: echo "Build or push failed, taking recovery steps or notifying stakeholders."
# Here, you could include a script to send notifications via Slack, email, or another service.
- name: Build, tag, and push image to Amazon ECR
id: build-image
continue-on-error: true
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: latest
REPOSITORY: auth_service
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ecom-app-task-definition-revision.json
container-name: auth-service
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ecom-app-service
cluster: DevCluster
wait-for-service-stability: true