Update CI/CD pipeline with improved workflow
Some checks failed
Complete CI/CD Pipeline / build-and-test (push) Has been cancelled
Complete CI/CD Pipeline / security-scan (push) Has been cancelled
Complete CI/CD Pipeline / deploy-dev (push) Has been cancelled
Complete CI/CD Pipeline / deploy-prod (push) Has been cancelled
Complete CI/CD Pipeline / cleanup (push) Has been cancelled

This commit is contained in:
2026-01-29 01:31:17 +00:00
parent b86157e8f5
commit 129d6d3e15

View File

@@ -1,43 +1,109 @@
name: CI/CD Pipeline
name: Complete CI/CD Pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'
- name: Install dependencies
run: npm install -g http-server
run: |
# No additional dependencies needed for static site
- name: Validate HTML
run: |
# Check if all required files exist
if [ ! -f index.html ]; then
echo "ERROR: index.html not found"
exit 1
fi
if [ ! -f styles.css ]; then
echo "ERROR: styles.css not found"
exit 1
fi
if [ ! -f script.js ]; then
echo "ERROR: script.js not found"
exit 1
fi
echo "All required files present"
- name: Run tests
run: |
# Add test commands here
echo "Running tests..."
ls -la
- name: Build
run: |
# Any build steps if needed
echo "Build completed"
deploy:
needs: build-and-test
runs-on: self-hosted
# Basic validation of files
cat index.html | head -20
echo "Test completed successfully"
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Deploy to server
- name: Security scan
run: |
# Copy files to web directory
# Simple security check for common vulnerabilities
echo "Checking for potential security issues..."
if grep -i "eval\|document.cookie\|window.location" script.js; then
echo "Potential security issues found"
else
echo "No obvious security issues found"
fi
deploy-dev:
needs: [build-and-test, security-scan]
runs-on: self-hosted
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Deploy to development server
run: |
# Create dev deployment directory
sudo mkdir -p /var/www/html/tic-tac-toe-dev
# Copy all necessary files
sudo cp -r index.html styles.css script.js README.md PROJECT_PLAN.md DEPLOYMENT.md DOCKER_DEPLOY.md PROJECT_SUMMARY.md /var/www/html/tic-tac-toe-dev/
# Set proper permissions
sudo chown -R www-data:www-data /var/www/html/tic-tac-toe-dev/
sudo chmod -R 644 /var/www/html/tic-tac-toe-dev/*
echo "Development deployment completed"
deploy-prod:
needs: [deploy-dev]
runs-on: self-hosted
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Deploy to production server
run: |
# Create prod deployment directory
sudo mkdir -p /var/www/html/tic-tac-toe
sudo cp -r ./index.html ./styles.css ./script.js ./PROJECT_PLAN.md ./README.md ./DEPLOYMENT.md ./DOCKER_DEPLOY.md /var/www/html/tic-tac-toe/
echo "Deployment completed"
# Copy all necessary files
sudo cp -r index.html styles.css script.js README.md PROJECT_PLAN.md DEPLOYMENT.md DOCKER_DEPLOY.md PROJECT_SUMMARY.md /var/www/html/tic-tac-toe/
# Set proper permissions
sudo chown -R www-data:www-data /var/www/html/tic-tac-toe/
sudo chmod -R 644 /var/www/html/tic-tac-toe/*
echo "Production deployment completed"
cleanup:
needs: [deploy-prod]
runs-on: self-hosted
if: github.ref == 'refs/heads/main'
steps:
- name: Cleanup temporary files
run: |
# Clean up any temporary files if needed
echo "Cleanup completed"