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
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:
@@ -1,43 +1,109 @@
|
|||||||
name: CI/CD Pipeline
|
name: Complete CI/CD Pipeline
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
build-and-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '16'
|
node-version: '18'
|
||||||
|
|
||||||
- name: Install dependencies
|
- 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
|
- name: Run tests
|
||||||
run: |
|
run: |
|
||||||
# Add test commands here
|
|
||||||
echo "Running tests..."
|
echo "Running tests..."
|
||||||
ls -la
|
ls -la
|
||||||
|
# Basic validation of files
|
||||||
|
cat index.html | head -20
|
||||||
|
echo "Test completed successfully"
|
||||||
|
|
||||||
- name: Build
|
security-scan:
|
||||||
run: |
|
runs-on: ubuntu-latest
|
||||||
# Any build steps if needed
|
|
||||||
echo "Build completed"
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
needs: build-and-test
|
|
||||||
runs-on: self-hosted
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Deploy to server
|
- name: Security scan
|
||||||
run: |
|
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 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/
|
# Copy all necessary files
|
||||||
echo "Deployment completed"
|
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"
|
||||||
Reference in New Issue
Block a user