Modernize 2025 clean #67
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: [ master, publish ] | |
| pull_request: | |
| branches: [ master, publish ] | |
| permissions: | |
| contents: write | |
| jobs: | |
| # Build job | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.3.5' | |
| bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'npm' | |
| - name: Install Node.js dependencies | |
| run: npm ci | |
| - name: Lint JavaScript | |
| run: npm run lint | |
| - name: Build site | |
| run: npm run build | |
| env: | |
| JEKYLL_ENV: production | |
| - name: Verify site assets | |
| run: | | |
| echo "=== Verifying critical site assets ===" | |
| # Check for CSS files | |
| if [ ! -f "_site/assets/styles/main.css" ]; then | |
| echo "❌ CRITICAL: main.css not found" | |
| exit 1 | |
| else | |
| echo "✅ main.css found ($(wc -c < _site/assets/styles/main.css) bytes)" | |
| fi | |
| # Check for JavaScript files | |
| if [ ! -f "_site/assets/scripts/main.min.js" ]; then | |
| echo "❌ CRITICAL: main.min.js not found" | |
| exit 1 | |
| else | |
| echo "✅ main.min.js found ($(wc -c < _site/assets/scripts/main.min.js) bytes)" | |
| fi | |
| # Check for essential fonts | |
| FONT_COUNT=$(find _site/assets/fonts -name "*.woff2" 2>/dev/null | wc -l) | |
| if [ "$FONT_COUNT" -lt 3 ]; then | |
| echo "❌ CRITICAL: Missing fonts (found $FONT_COUNT, expected at least 3)" | |
| exit 1 | |
| else | |
| echo "✅ Fonts found ($FONT_COUNT .woff2 files)" | |
| fi | |
| # Check for favicon | |
| if [ ! -f "_site/assets/graphics/favicon/favicon.ico" ]; then | |
| echo "❌ WARNING: favicon.ico not found" | |
| else | |
| echo "✅ favicon.ico found" | |
| fi | |
| # Check for critical pages | |
| CRITICAL_PAGES=("index.html" "about/index.html" "beginner/index.html" "host/index.html" "blog/index.html") | |
| for page in "${CRITICAL_PAGES[@]}"; do | |
| if [ ! -f "_site/$page" ]; then | |
| echo "❌ CRITICAL: Page $page not found" | |
| exit 1 | |
| else | |
| echo "✅ Page $page found" | |
| fi | |
| done | |
| # Check for language versions | |
| LANGUAGES=("en" "es" "fr" "cs") | |
| for lang in "${LANGUAGES[@]}"; do | |
| if [ "$lang" = "en" ]; then | |
| # English is at root | |
| if [ ! -f "_site/index.html" ]; then | |
| echo "❌ CRITICAL: English homepage not found" | |
| exit 1 | |
| fi | |
| else | |
| if [ ! -f "_site/$lang/index.html" ]; then | |
| echo "❌ CRITICAL: $lang homepage not found" | |
| exit 1 | |
| else | |
| echo "✅ $lang homepage found" | |
| fi | |
| fi | |
| done | |
| # Summary statistics | |
| TOTAL_FILES=$(find _site -type f | wc -l) | |
| TOTAL_SIZE=$(du -sh _site | cut -f1) | |
| echo "" | |
| echo "=== Build Summary ===" | |
| echo "Total files: $TOTAL_FILES" | |
| echo "Total size: $TOTAL_SIZE" | |
| echo "✅ All critical assets verified successfully" | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: site-build | |
| path: _site/ | |
| retention-days: 1 | |
| # Deployment job - push built files to master branch | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: github.ref == 'refs/heads/publish' && github.event_name == 'push' | |
| steps: | |
| - name: Checkout master branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: master | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: site-build | |
| path: _site/ | |
| - name: Verify build artifacts | |
| run: | | |
| echo "Checking _site directory contents:" | |
| ls -la _site/ || echo "No _site directory found" | |
| if [ ! -d "_site" ] || [ -z "$(ls -A _site)" ]; then | |
| echo "Error: _site directory is empty or missing" | |
| exit 1 | |
| fi | |
| - name: Deploy to master branch | |
| run: | | |
| # Configure git | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| # Debug: Show current directory contents | |
| echo "=== Before cleanup ===" | |
| ls -la | |
| # Remove all files except .git and _site (more targeted approach) | |
| shopt -s dotglob | |
| for item in *; do | |
| if [[ "$item" != ".git" && "$item" != "_site" ]]; then | |
| echo "Removing: $item" | |
| rm -rf "$item" | |
| fi | |
| done | |
| shopt -u dotglob | |
| # Debug: Show directory after cleanup | |
| echo "=== After cleanup ===" | |
| ls -la | |
| # Debug: Show _site contents | |
| echo "=== _site directory contents ===" | |
| ls -la _site/ | |
| # Copy built site files to root with verification | |
| if [ -d "_site" ] && [ "$(ls -A _site)" ]; then | |
| echo "Copying _site contents to root..." | |
| # Use rsync for more reliable copying | |
| rsync -av --exclude='.git' _site/ . | |
| # Alternative: Use find and cp for better reliability | |
| # find _site -mindepth 1 -maxdepth 1 -exec cp -r {} . \; | |
| echo "Copy completed. Removing _site directory..." | |
| rm -rf _site | |
| else | |
| echo "Error: _site directory is empty or does not exist" | |
| exit 1 | |
| fi | |
| # Debug: Show final directory structure | |
| echo "=== Final directory structure ===" | |
| ls -la | |
| echo "=== assets directory ===" | |
| ls -la assets/ || echo "No assets directory found" | |
| echo "=== assets/styles directory ===" | |
| ls -la assets/styles/ || echo "No assets/styles directory found" | |
| echo "=== Checking for main.css ===" | |
| find . -name "main.css" -type f || echo "main.css not found" | |
| # Add and commit changes | |
| git add -A | |
| if git diff --staged --quiet; then | |
| echo "No changes to deploy" | |
| else | |
| echo "Committing and pushing changes..." | |
| git commit -m "CI deploy to gh-pages from publish@${{ github.sha }}" | |
| git push origin master | |
| fi |