Skip to content

fix_task_def_syntax_error #5

fix_task_def_syntax_error

fix_task_def_syntax_error #5

Workflow file for this run

# This workflow will build and push a new container image to Amazon ECR,
# and then will deploy a new task definition to Amazon ECS, when there is a push to the "staging" branch.
name: Deploy to Staging
# Stop any pending jobs
concurrency:
group: staging
cancel-in-progress: true
on:
push:
branches: [ "enhancements/add-tf-iac" ]
env:
AWS_REGION: us-east-1
ECR_REPOSITORY: appointment
ECS_SERVICE: staging-appointment
ECS_CLUSTER: staging-appointment
BACKEND_TASK_DEFINITION: .aws/staging-appointment-backend-task-definition.json
FRONTEND_TASK_DEFINITION: .aws/staging-appointment-frontend-task-definition.json
CONTAINER_FRONTEND: frontend
CONTAINER_BACKEND: backend
permissions:
contents: read
jobs:
deploy:
name: Build & Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'
- name: Build, tag, and push backend to Amazon ECR
id: build-backend
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: backend-${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./backend -f ./backend/deploy.dockerfile
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image_backend=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Build, tag, and push frontend to Amazon ECR
id: build-frontend
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: frontend-${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./frontend -f ./frontend/deploy.dockerfile
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image_frontend=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Render ECS backend task definition
id: render-backend-task-definition
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.BACKEND_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_BACKEND }}
image: ${{ steps.build-backend.outputs.image_backend }}
environment-variables: "RELEASE_VERSION=${{ github.sha }}"
- name: Render ECS frontend task definition
id: render-frontend-task-definition
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.FRONTEND_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_FRONTEND }}
image: ${{ steps.build-frontend.outputs.image_frontend }}
- name: Deploy Staging ECS backend task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-backend-task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
- name: Deploy Staging ECS frontend task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-frontend-task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true