Files
narrow_casting_system/.github/workflows/ci.yml
Alvin-Zilverstand 50c0648476 🔧 Fix GitHub Actions CI/CD pipeline and improve project structure
- Split CI workflow into separate backend and admin testing jobs
- Fix package-lock.json caching issues with proper cache paths
- Update Docker configuration for better CI/CD integration
- Improve root package.json with comprehensive npm scripts
- Add proper build and test scripts for all components
- Fix Dockerfile to work correctly with GitHub Actions
- Add Docker BuildKit support for faster builds
- Organize project structure with deployment folder

This fixes the GitHub Actions error about missing package-lock.json
and improves the overall CI/CD pipeline for the project.
2026-01-19 10:05:57 +01:00

139 lines
3.0 KiB
YAML

name: CI/CD Pipeline
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
jobs:
test-backend:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }} for Backend
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install backend dependencies
run: |
cd backend
npm ci
- name: Run backend tests
run: |
cd backend
npm start &
sleep 5
cd ..
node test_system.js
pkill -f "node server.js" || true
- name: Security audit backend
run: |
cd backend
npm audit --audit-level=high
test-admin:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js ${{ matrix.node-version }} for Admin
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: admin/package-lock.json
- name: Install admin dependencies
run: |
cd admin
npm ci
- name: Security audit admin
run: |
cd admin
npm audit --audit-level=high
build:
needs: [test-backend, test-admin]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install all dependencies
run: npm run setup
- name: Build project
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: project-files
path: |
backend/
admin/
client/
docs/
deployment/
package.json
README.md
!backend/node_modules/
!admin/node_modules/
docker:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./deployment/docker/Dockerfile
push: true
tags: |
snowworld/narrowcasting:latest
snowworld/narrowcasting:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
env:
DOCKER_BUILDKIT: 1