mirror of
https://github.com/Alvin-Zilverstand/narrow_casting_system.git
synced 2026-03-06 02:57:17 +01:00
- Update docker-compose.yml to use modern 'docker compose' syntax (v2) - Fix GitHub Actions Docker login to use GitHub Container Registry (ghcr.io) - Add comprehensive GitHub repository settings documentation - Add alternative CI/CD workflow without Docker push requirement - Update package.json scripts for modern Docker commands - Add Docker security scanning and metadata extraction - Add repository permissions configuration for GitHub Actions - Update Docker documentation with modern practices This addresses the Docker login issues and modernizes the deployment process while providing fallback options for CI/CD implementation.
147 lines
3.5 KiB
YAML
147 lines
3.5 KiB
YAML
name: CI/CD Pipeline - SnowWorld Narrowcasting
|
|
|
|
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
|
|
echo "Backend dependencies installed with security audit warnings noted"
|
|
|
|
- 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
|
|
echo "Running security audit..."
|
|
npm audit --audit-level=moderate || echo "Security audit completed with warnings - see SECURITY_CONSIDERATIONS.md"
|
|
|
|
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
|
|
echo "Admin dependencies installed successfully"
|
|
|
|
- name: Security audit admin
|
|
run: |
|
|
cd admin
|
|
echo "Running security audit..."
|
|
npm audit --audit-level=moderate || echo "Security audit completed"
|
|
|
|
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'
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: ./deployment/docker/Dockerfile
|
|
push: true
|
|
tags: |
|
|
ghcr.io/${{ github.repository }}:latest
|
|
ghcr.io/${{ github.repository }}:${{ github.sha }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
env:
|
|
DOCKER_BUILDKIT: 1 |