Skip to content

updates the files for deployment #12

updates the files for deployment

updates the files for deployment #12

Workflow file for this run

name: Frontend CI/CD
on:
push:
branches: [main]
paths:
- "front-end/**"
- ".github/workflows/front-end.yml"
jobs:
build-frontend:
runs-on: ubuntu-latest
timeout-minutes: 15
defaults:
run:
working-directory: front-end
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "24.8.0"
- name: Install dependencies
run: npm install
- name: Build frontend
run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: frontend-build
path: front-end/dist/
deploy-frontend:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: build-frontend
steps:
- name: Checkout code
uses: actions/checkout@v4
# Download artifact to front-end/dist/
- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: frontend-build
path: front-end/dist/
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: ./front-end
file: ./front-end/Dockerfile
push: true
tags: |
${{ secrets.DOCKER_HUB_USERNAME }}/frontend-aws-integration:v1.0.${{ github.run_number }}
# --- AWS ECR Public Login + Push ---
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Login to Amazon ECR Public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- name: Tag and push to ECR Public (frontend)
run: |
IMAGE_TAG=v1.0.${{ github.run_number }}
ECR_URI=public.ecr.aws/d9h7a7q0/saadsabahuddin/front-end
docker tag ${{ secrets.DOCKER_HUB_USERNAME }}/frontend-aws-integration:$IMAGE_TAG $ECR_URI:$IMAGE_TAG
docker push $ECR_URI:$IMAGE_TAG
- name: Register new task definition with updated image (frontend)
run: |
IMAGE_TAG=v1.0.${GITHUB_RUN_NUMBER}
ECR_URI=public.ecr.aws/d9h7a7q0/saadsabahuddin/front-end
# Get current task definition JSON
TASK_DEF_JSON=$(aws ecs describe-task-definition \
--task-definition front-end-td \
--query 'taskDefinition' \
--output json)
# Update the container image
NEW_TASK_DEF=$(echo $TASK_DEF_JSON | jq --arg IMAGE "$ECR_URI:$IMAGE_TAG" \
'.containerDefinitions[0].image=$IMAGE | del(.status,.revision,.taskDefinitionArn,.requiresAttributes,.compatibilities,.registeredAt,.registeredBy)')
# Register new task definition revision
aws ecs register-task-definition \
--cli-input-json "$NEW_TASK_DEF"
- name: Update ECS service (frontend)
run: |
# Get the new revision number
NEW_REV=$(aws ecs describe-task-definition --task-definition front-end-td | jq '.taskDefinition.revision')
# Force ECS service to use the new task definition
aws ecs update-service \
--cluster spring-boot-react-aws-integration \
--service front-end-service \
--task-definition front-end-td:$NEW_REV \
--force-new-deployment