Readme.md #35
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: Deploy MindVault | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
# Update the checkout action to v4 | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
# Update the setup-buildx-action to v3 | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
# Update the login-action to v3 | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Build and push backend image | |
run: | | |
docker build -t mohammadshahidbeigh/mindvault-backend:latest ./mindvault-backend | |
docker push mohammadshahidbeigh/mindvault-backend:latest | |
- name: Build and push frontend image | |
run: | | |
docker build -t mohammadshahidbeigh/mindvault-frontend:latest . | |
docker push mohammadshahidbeigh/mindvault-frontend:latest | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to EC2 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_PUBLIC_IP }} | |
username: ubuntu | |
key: ${{ secrets.EC2_SSH_KEY }} | |
port: 22 | |
script: | | |
docker pull mohammadshahidbeigh/mindvault-backend:latest | |
docker pull mohammadshahidbeigh/mindvault-frontend:latest | |
docker stop $(docker ps -q) | |
docker run -d -p 4000:4000 mohammadshahidbeigh/mindvault-backend:latest | |
docker run -d -p 3000:80 mohammadshahidbeigh/mindvault-frontend:latest | |