Skip to content

Merge pull request #3 from xrey167/claude/github-userstory-factory-wo… #21

Merge pull request #3 from xrey167/claude/github-userstory-factory-wo…

Merge pull request #3 from xrey167/claude/github-userstory-factory-wo… #21

Workflow file for this run

ο»Ώ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