Merge pull request #79 from abolfazlakbarzadeh/feat/split-openai-embe… #181
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 | ||
| permissions: | ||
| contents: read | ||
| on: | ||
| push: | ||
| branches: [ main, develop ] | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
| jobs: | ||
| validate: | ||
| name: Validate Code | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| node-version: [21.x] | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
| - name: Setup Node.js ${{ matrix.node-version }} | ||
| uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: ${{ matrix.node-version }} | ||
| cache: 'npm' | ||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 8 | ||
| # Backend validation | ||
| - name: Install backend dependencies | ||
| run: npm install | ||
| working-directory: ./ | ||
| - name: Build backend | ||
| run: npm run build | ||
| # Frontend validation | ||
| - name: Install frontend dependencies | ||
| run: pnpm install | ||
| working-directory: ./frontend | ||
| - name: Build frontend | ||
| run: pnpm run build | ||
| working-directory: ./frontend | ||
| # Security and dependency checks | ||
| - name: Run npm audit (backend) | ||
| run: npm audit --audit-level=moderate | ||
| continue-on-error: true | ||
| - name: Run pnpm audit (frontend) | ||
| run: pnpm audit --audit-level=moderate | ||
| working-directory: ./frontend | ||
| continue-on-error: true | ||
| docker-build: | ||
| name: Docker Build Test | ||
| runs-on: ubuntu-latest | ||
| needs: validate | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
| - name: Build backend Docker image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| file: ./backend/Dockerfile | ||
| push: false | ||
| tags: pagelm-backend:test | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| - name: Build frontend Docker image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: ./frontend | ||
| file: ./frontend/Dockerfile | ||
| push: false | ||
| tags: pagelm-frontend:test | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| dependency-check: | ||
| name: Dependency Vulnerability Check | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v5 | ||
| with: | ||
| node-version: '20.x' | ||
| - name: Install dependencies (backend) | ||
| run: npm install | ||
| - name: Check for known vulnerabilities (backend) | ||
| run: npm audit --audit-level=high | ||
| continue-on-error: false | ||
| - name: Setup pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 8 | ||
| - name: Install dependencies (frontend) | ||
| run: pnpm install | ||
| working-directory: ./frontend | ||
| - name: Check for known vulnerabilities (frontend) | ||
| run: pnpm audit --audit-level=high | ||
| working-directory: ./frontend | ||
| continue-on-error: false | ||
| summary: | ||
| name: Validation Summary | ||
| runs-on: ubuntu-latest | ||
| needs: [validate, docker-build, dependency-check] | ||
| if: always() | ||
| steps: | ||
| - name: Check results | ||
| run: | | ||
| if [[ "${{ needs.validate.result }}" == "failure" || | ||
| "${{ needs.docker-build.result }}" == "failure" || | ||
| "${{ needs.dependency-check.result }}" == "failure" ]]; then | ||
| echo "❌ Some validation checks failed" | ||
| exit 1 | ||
| else | ||
| echo "✅ All validation checks passed" | ||
| fi | ||