Modernize 2025 #56
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: 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: 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@v5 | |
| with: | |
| name: site-build | |
| path: _site/ | |
| - name: Deploy to master branch | |
| run: | | |
| # Configure git | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| # Remove all files except .git | |
| find . -maxdepth 1 ! -name '.git' ! -name '.' ! -name '..' -exec rm -rf {} + | |
| # Copy built site files to root | |
| cp -r _site/* . | |
| rm -rf _site | |
| # Add and commit changes | |
| git add -A | |
| if git diff --staged --quiet; then | |
| echo "No changes to deploy" | |
| else | |
| git commit -m "CI deploy to gh-pages from publish@${{ github.sha }}" | |
| git push origin master | |
| fi |