Posts Refeactor #19
Workflow file for this run
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: Deploy Staging Preview | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| workflow_dispatch: # Allow manual trigger | |
| permissions: | |
| contents: write | |
| concurrency: staging-preview | |
| jobs: | |
| deploy-staging: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.1' | |
| bundler-cache: true | |
| - name: Show staging content | |
| run: | | |
| echo "=== Staging content ===" | |
| echo "Staging posts:" | |
| find staging/ -name "*.md" -not -name "README.md" -not -name "index.md" | sort || echo " (none)" | |
| echo "Published posts:" | |
| ls -1 _posts/*.md 2>/dev/null | head -5 || echo " (none)" | |
| - name: Build with Jekyll | |
| run: bundle exec jekyll build | |
| env: | |
| JEKYLL_ENV: production | |
| - name: Deploy to gh-pages | |
| run: | | |
| # Switch to gh-pages branch | |
| git fetch origin gh-pages:gh-pages || git checkout --orphan gh-pages | |
| git checkout gh-pages | |
| # Clear and copy site | |
| rm -rf * 2>/dev/null || true | |
| cp -r _site/* ./ 2>/dev/null || true | |
| # Commit and push | |
| git add -A | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| git commit -m "Deploy preview from PR #${{ github.event.number }}" || exit 0 | |
| git push origin gh-pages |