update deploy.yml #22
This file contains hidden or 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 for Project Manager | |
| on: | |
| push: | |
| branches: [ "main" ] # Triggers on push to the main branch | |
| pull_request: | |
| branches: [ "main" ] # Also triggers on pull requests to main | |
| jobs: | |
| #------------------------- | |
| # BACKEND CI/CD | |
| #------------------------- | |
| backend: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./backend | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' # version compatible with the project | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Run backend tests | |
| run: npm test | |
| env: | |
| MONGO_URI: ${{ secrets.MONGO_URI }} # Using secrets for sensitive data | |
| JWT_SECRET: ${{ (github.event.pull_request.head.repo.fork == true) && 'a-safe-default-secret-for-testing' || secrets.JWT_SECRET }} | |
| # Backend deployment (Render) step | |
| #------------------------- | |
| # FRONTEND CI/CD | |
| #------------------------- | |
| frontend: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./frontend | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Run linter | |
| run: npm run lint | |
| - name: Build the frontend | |
| run: npm run build | |
| env: | |
| VITE_API_URL: ${{ secrets.VITE_API_URL }} | |
| VITE_SOCKET_URL: ${{ secrets.VITE_SOCKET_URL }} | |
| # Frontend deployment (Vercel) step |