From 84d2676477b00480f1ebb5bda4eed679b3236e5e Mon Sep 17 00:00:00 2001 From: Jefferson Gomes Date: Fri, 12 Jul 2024 15:53:42 -0300 Subject: [PATCH] - Add GitHub Actions workflow for CI/CD --- .github/workflows/deploy.yml | 80 ++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..42567f7 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,80 @@ +name: CI/CD Pipeline + +on: + push: + branches: + - main + - develop + pull_request: + branches: + - main + - develop + +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: Install dependencies + working-directory: ./backend + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run tests + working-directory: ./backend + run: | + # Add your test command here + pytest + + 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 + + deploy-frontend: + name: Deploy Frontend to GitHub Pages + runs-on: ubuntu-latest + needs: build-frontend + if: github.ref == 'refs/heads/main' + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Deploy to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4.1.5 + with: + branch: develop + folder: frontend/dist