Build and deploy MERN stack #4
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: machine1 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4.1.7 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3.2.0 | |
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: Create and claim persistent volume | |
run: | | |
sudo su | |
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 |