--- name: Debian Image Builder Frontend CI/CD on: push: branches: [main, develop] pull_request: branches: [main] workflow_dispatch: env: NODE_VERSION: "18" DEBIAN_FRONTEND: noninteractive jobs: build-and-test: name: Build and Test Frontend runs-on: ubuntu-latest container: image: node:18-bullseye steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js environment run: | node --version npm --version - name: Install build dependencies run: | apt-get update apt-get install -y \ build-essential \ git \ ca-certificates \ python3 - name: Install Node.js dependencies run: | npm ci npm run build || echo "Build script not found" - name: Run tests run: | if [ -f package.json ] && npm run test; then npm test else echo "No test script found, skipping tests" fi - name: Run linting run: | if [ -f package.json ] && npm run lint; then npm run lint else echo "No lint script found, skipping linting" fi - name: Build production bundle run: | if [ -f package.json ] && npm run build; then npm run build else echo "No build script found" fi - name: Upload build artifacts uses: actions/upload-artifact@v4 with: name: frontend-build path: | dist/ build/ retention-days: 30 package: name: Package Frontend runs-on: ubuntu-latest container: image: node:18-bullseye needs: build-and-test steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js environment run: | node --version npm --version - name: Install build dependencies run: | apt-get update apt-get install -y \ build-essential \ devscripts \ debhelper \ git \ ca-certificates \ python3 - name: Install Node.js dependencies run: npm ci - name: Build production bundle run: | if [ -f package.json ] && npm run build; then npm run build else echo "No build script found" fi - name: Create debian directory run: | mkdir -p debian cat > debian/control << EOF Source: debian-image-builder-frontend Section: web Priority: optional Maintainer: Debian Forge Team Build-Depends: debhelper (>= 13), nodejs, npm, git, ca-certificates Standards-Version: 4.6.2 Package: debian-image-builder-frontend Architecture: all Depends: \${misc:Depends}, nodejs, nginx Description: Debian Image Builder Frontend Web-based frontend for Debian Image Builder with Cockpit integration. Provides a user interface for managing image builds, blueprints, and system configurations through a modern React application. EOF cat > debian/rules << EOF #!/usr/bin/make -f %: dh \$@ override_dh_auto_install: dh_auto_install mkdir -p debian/debian-image-builder-frontend/usr/share/debian-image-builder-frontend mkdir -p debian/debian-image-builder-frontend/etc/nginx/sites-available mkdir -p debian/debian-image-builder-frontend/etc/cockpit # Copy built frontend files if [ -d dist ]; then cp -r dist/* debian/debian-image-builder-frontend/usr/share/debian-image-builder-frontend/ elif [ -d build ]; then cp -r build/* debian/debian-image-builder-frontend/usr/share/debian-image-builder-frontend/ fi # Copy source files for development cp -r src debian/debian-image-builder-frontend/usr/share/debian-image-builder-frontend/ cp package.json debian/debian-image-builder-frontend/usr/share/debian-image-builder-frontend/ # Create nginx configuration cat > debian/debian-image-builder-frontend/etc/nginx/sites-available/debian-image-builder-frontend << 'NGINX_EOF' server { listen 80; server_name localhost; root /usr/share/debian-image-builder-frontend; index index.html; location / { try_files \$uri \$uri/ /index.html; } location /api/ { proxy_pass http://localhost:8080/; proxy_set_header Host \$host; proxy_set_header X-Real-IP \$remote_addr; } } NGINX_EOF # Create cockpit manifest cat > debian/debian-image-builder-frontend/etc/cockpit/debian-image-builder.manifest << 'COCKPIT_EOF' { "version": 1, "manifest": { "name": "debian-image-builder", "version": "1.0.0", "title": "Debian Image Builder", "description": "Build and manage Debian atomic images", "url": "/usr/share/debian-image-builder-frontend", "icon": "debian-logo", "requires": { "cockpit": ">= 200" } } } COCKPIT_EOF EOF cat > debian/changelog << EOF debian-image-builder-frontend (1.0.0-1) unstable; urgency=medium * Initial release * Debian Image Builder Frontend with Cockpit integration * React-based web interface for image management -- Debian Forge Team $(date -R) EOF cat > debian/compat << EOF 13 EOF chmod +x debian/rules - name: Build Debian package run: | dpkg-buildpackage -us -uc -b ls -la ../*.deb - name: Upload Debian package uses: actions/upload-artifact@v4 with: name: debian-image-builder-frontend-deb path: ../*.deb retention-days: 30 cockpit-integration: name: Test Cockpit Integration runs-on: ubuntu-latest container: image: node:18-bullseye needs: build-and-test steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Node.js environment run: | node --version npm --version - name: Install Node.js dependencies run: npm ci - name: Test cockpit integration run: | echo "Testing Cockpit integration..." if [ -d cockpit ]; then echo "Cockpit directory found:" ls -la cockpit/ else echo "No cockpit directory found" fi if [ -f package.json ]; then echo "Package.json scripts:" npm run fi