Build and deploy MERN stack #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and deploy MERN stack | |
on: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/[email protected] | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: us-east-1 | |
aws-access-key-id: ${{ secrets.AWS_SECRET_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
- name: Login to DockerHub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
run: | | |
docker build -t hellopradum/backend-wanderlust backend/. | |
docker build -t hellopradum/frontend-wanderlust frontend/. | |
docker push hellopradum/backend-wanderlust:latest | |
docker push hellopradum/frontend-wanderlust:latest | |
- name: Update kubeconfig | |
run: aws eks update-kubeconfig --name demo-ekscluster | |
- name: Create and claim persistent volume | |
run: | | |
kubectl apply -f kubernetes/persistentVolume.yaml | |
kubectl apply -f kubernetes/persistentVolumeClaim.yaml | |
- name: Deploy MongoDB | |
run: | | |
kubectl apply -f kubernetes/mongodb.yaml | |
- name: Deploy Redis | |
run: | | |
kubectl apply -f kubernetes/redis.yaml | |
- name: Deploy Backend | |
run: | | |
kubectl apply -f kubernetes/backend.yaml | |
- name: Deploy Frontend | |
run: | | |
kubectl apply -f kubernetes/frontend.yaml |