removin useless info #2
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 | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| branches: [ main, develop ] | |
| env: | |
| NODE_VERSION: '18' | |
| PYTHON_VERSION: '3.9' | |
| jobs: | |
| # Frontend CI Job | |
| frontend-ci: | |
| runs-on: ubuntu-latest | |
| if: contains(github.event.head_commit.message, '[skip ci]') == false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run linter | |
| run: npm run lint | |
| - name: Run type check | |
| run: npm run type-check | |
| continue-on-error: true | |
| - name: Run tests | |
| run: npm run test | |
| - name: Build application | |
| run: npm run build | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-files | |
| path: | | |
| dist/ | |
| build/ | |
| .next/ | |
| retention-days: 7 | |
| # Backend CI Job (Firebase Functions) | |
| backend-ci: | |
| runs-on: ubuntu-latest | |
| if: contains(github.event.head_commit.message, '[skip ci]') == false && (contains(github.event.head_commit.message, 'functions') || contains(github.event.head_commit.message, 'backend')) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: 'functions/package-lock.json' | |
| - name: Install Firebase CLI | |
| run: npm install -g firebase-tools | |
| - name: Install functions dependencies | |
| run: | | |
| cd functions | |
| npm ci | |
| - name: Run functions linter | |
| run: | | |
| cd functions | |
| npm run lint | |
| - name: Build functions | |
| run: | | |
| cd functions | |
| npm run build | |
| # Python Backend CI Job (if applicable) | |
| python-backend-ci: | |
| runs-on: ubuntu-latest | |
| if: contains(github.event.head_commit.message, '[skip ci]') == false && contains(github.event.head_commit.message, 'python') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Install Python dependencies | |
| run: | | |
| if [ -f requirements.txt ]; then | |
| pip install -r requirements.txt | |
| fi | |
| if [ -f functions-python/requirements.txt ]; then | |
| pip install -r functions-python/requirements.txt | |
| fi | |
| - name: Run Python linter | |
| run: | | |
| if [ -f requirements.txt ] || [ -f functions-python/requirements.txt ]; then | |
| pip install flake8 | |
| flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
| fi | |
| # Security Scan | |
| security-scan: | |
| runs-on: ubuntu-latest | |
| if: contains(github.event.head_commit.message, '[skip ci]') == false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Run npm audit | |
| run: npm audit --audit-level=high | |
| continue-on-error: true | |
| - name: Run Trivy vulnerability scanner | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| scan-type: 'fs' | |
| scan-ref: '.' | |
| format: 'sarif' | |
| output: 'trivy-results.sarif' | |
| continue-on-error: true | |
| # Deploy Job (only on main branch) | |
| deploy: | |
| needs: [frontend-ci, backend-ci] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[skip deploy]') == false | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build for production | |
| run: npm run build | |
| - name: Install Firebase CLI | |
| run: npm install -g firebase-tools | |
| - name: Deploy to Firebase | |
| run: firebase deploy --token ${{ secrets.FIREBASE_TOKEN }} --project ${{ secrets.FIREBASE_PROJECT_ID }} | |
| env: | |
| FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} | |
| FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }} |