Merge pull request #3 from xrey167/claude/github-userstory-factory-wo⦠#21
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, feature/*] | |
| pull_request: | |
| branches: [main, develop] | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: "Deployment Environment" | |
| required: true | |
| default: "staging" | |
| type: choice | |
| options: | |
| - staging | |
| - production | |
| env: | |
| NODE_VERSION: "18" | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| lint-and-format: | |
| name: π Lint & Format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: β¬οΈ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: βοΈ Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| - name: π¦ Install dependencies | |
| run: npm ci | |
| - name: π Run ESLint | |
| run: npm run lint | |
| - name: β¨ Check Prettier formatting | |
| run: npm run format:check | |
| - name: π Run security audit | |
| run: npm audit --audit-level=moderate | |
| test: | |
| name: π§ͺ Test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [18, 20] | |
| steps: | |
| - name: β¬οΈ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: βοΈ Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: "npm" | |
| - name: π¦ Install dependencies | |
| run: npm ci | |
| - name: π§ͺ Run unit tests | |
| run: npm run test:unit | |
| - name: π Run integration tests | |
| run: npm run test:integration | |
| - name: π Upload coverage to Codecov | |
| if: matrix.node-version == 18 | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage/lcov.info | |
| build: | |
| name: ποΈ Build | |
| runs-on: ubuntu-latest | |
| needs: [lint-and-format, test] | |
| steps: | |
| - name: β¬οΈ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: βοΈ Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: "npm" | |
| - name: π¦ Install dependencies | |
| run: npm ci | |
| - name: ποΈ Build application | |
| run: npm run build | |
| - name: π Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-files | |
| path: dist/ | |
| retention-days: 30 | |
| security-scan: | |
| name: π Security Scan | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main' | |
| permissions: | |
| security-events: write | |
| steps: | |
| - name: β¬οΈ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: π Run CodeQL Analysis | |
| uses: github/codeql-action/init@v2 | |
| with: | |
| languages: javascript | |
| - name: π Perform CodeQL Analysis | |
| uses: github/codeql-action/analyze@v2 | |
| deploy-staging: | |
| name: π Deploy to Staging | |
| runs-on: ubuntu-latest | |
| needs: [build] | |
| if: github.ref == 'refs/heads/develop' | |
| environment: | |
| name: staging | |
| url: https://staging.example.com | |
| steps: | |
| - name: π Deploy to staging | |
| run: | | |
| echo "Deploying to staging environment..." | |
| # Add your deployment script here | |
| deploy-production: | |
| name: π― Deploy to Production | |
| runs-on: ubuntu-latest | |
| needs: [build, security-scan] | |
| if: github.ref == 'refs/heads/main' | |
| environment: | |
| name: production | |
| url: https://example.com | |
| steps: | |
| - name: π― Deploy to production | |
| run: | | |
| echo "Deploying to production environment..." | |
| # Add your deployment script here |