Update deploy workflow and Dockerfile for backend #21
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 to Production | |
on: | |
push: | |
branches: | |
- "deploy" | |
jobs: | |
build-frontend: | |
name: Building Frontend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Establish ssh connection | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
key: ${{ secrets.SSH_KEY }} | |
passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
port: ${{ secrets.SSH_PORT }} | |
username: ${{ secrets.SSH_USERNAME }} | |
script: | | |
cd /webapps/StudentsPortal/Frontend | |
git fetch origin | |
git checkout deploy | |
git pull | |
docker compose -f docker-compose.yml up -d --build | |
build-backend: | |
name: Building Backend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Establish ssh connection | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
key: ${{ secrets.SSH_KEY }} | |
passphrase: ${{ secrets.SSH_PASSPHRASE }} | |
port: ${{ secrets.SSH_PORT }} | |
username: ${{ secrets.SSH_USERNAME }} | |
- name: List Directories and Navigate to Backend | |
run: | | |
ls /webapps | tee ls-output.log | |
cd /webapps/StudentsPortal/Backend | |
- name: Fetch Latest Changes from Git | |
run: | | |
git fetch origin | |
- name: Switch to Deploy Branch | |
run: | | |
git checkout deploy | |
- name: Pull Latest Changes | |
run: | | |
git pull | tee git-pull.log | |
- name: Build and Start Docker Containers | |
run: | | |
docker compose -f docker-compose.yml up -d --build | tee docker-compose.log |