81 lines
1.6 KiB
YAML
81 lines
1.6 KiB
YAML
name: CI/CD Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, develop ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: host
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '18'
|
|
cache: 'npm'
|
|
|
|
# Backend tests
|
|
- name: Install backend dependencies
|
|
run: |
|
|
cd backend
|
|
npm ci
|
|
|
|
- name: Run backend linting
|
|
run: |
|
|
cd backend
|
|
npm run lint
|
|
|
|
- name: Run backend tests
|
|
env:
|
|
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/nfoguard_test
|
|
JWT_SECRET: test-secret-key-for-ci
|
|
NODE_ENV: test
|
|
run: |
|
|
cd backend
|
|
npm run test
|
|
|
|
# Frontend tests
|
|
- name: Install frontend dependencies
|
|
run: |
|
|
cd frontend
|
|
npm ci
|
|
|
|
- name: Run frontend linting
|
|
run: |
|
|
cd frontend
|
|
npm run lint
|
|
|
|
- name: Run frontend tests
|
|
run: |
|
|
cd frontend
|
|
npm run test
|
|
|
|
- name: Build frontend
|
|
run: |
|
|
cd frontend
|
|
npm run build
|
|
|
|
deploy:
|
|
needs: test
|
|
runs-on: host
|
|
if: github.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Deploy application
|
|
run: |
|
|
echo "Deploying to production..."
|
|
# Add your deployment commands here
|
|
# Examples:
|
|
# docker-compose down
|
|
# docker-compose pull
|
|
# docker-compose up -d
|
|
# or systemctl restart nfoguard |