- up #23
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: CI/CD Pipeline | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-backend: | |
name: Build and Test Backend | |
runs-on: ubuntu-latest | |
services: | |
mongo: | |
image: mongo:latest | |
ports: | |
- 27017:27017 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Create and activate virtual environment | |
working-directory: ./backend | |
run: | | |
python -m venv venv | |
source venv/bin/activate | |
python -m pip install --upgrade pip | |
pip install -r backend/requirements.txt | |
- name: Run Test | |
working-directory: ./backend | |
env: | |
MONGO_URI: "mongodb://localhost:27017/jreport" | |
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }} | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
run: | | |
source venv/bin/activate | |
pytest --disable-warnings | |
build-frontend: | |
name: Build Frontend | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
working-directory: ./frontend | |
run: npm install | |
- name: Build project | |
working-directory: ./frontend | |
run: npm run build | |
- name: List files | |
run: ls -la ./frontend/dist | |
deploy-frontend: | |
runs-on: ubuntu-latest | |
needs: build-frontend | |
if: github.ref == 'refs/heads/develop' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Deploy to GitHub Pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: develop | |
folder: ./frontend/dist | |
clean: true |