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
109 lines
3.1 KiB
YAML
109 lines
3.1 KiB
YAML
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@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '18'
|
|
|
|
- name: Install dependencies
|
|
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: |
|
|
echo "Running tests..."
|
|
ls -la
|
|
# Basic validation of files
|
|
cat index.html | head -20
|
|
echo "Test completed successfully"
|
|
|
|
security-scan:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Security scan
|
|
run: |
|
|
# 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
|
|
# 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" |