Posts Refeactor #9
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 PR Preview | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - reopened | |
| - synchronize | |
| - closed | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| concurrency: preview-${{ github.ref }} | |
| jobs: | |
| deploy-preview: | |
| 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: Setup staging for preview | |
| if: github.event.action != 'closed' | |
| run: | | |
| # Copy any new or modified post files to staging directory | |
| # This allows preview of posts before they go live | |
| mkdir -p staging | |
| # Find modified .md files in _posts directory from this PR | |
| git diff --name-only origin/main...HEAD | grep "^_posts/.*\.md$" | while read file; do | |
| if [ -f "$file" ]; then | |
| echo "Staging post: $file" | |
| cp "$file" "staging/$(basename "$file")" | |
| fi | |
| done | |
| # List staged files for debugging | |
| echo "Staged posts:" | |
| ls -la staging/ || echo "No posts staged" | |
| - name: Build Jekyll site | |
| if: github.event.action != 'closed' | |
| run: | | |
| # Remove CNAME file for previews to avoid routing conflicts | |
| rm -f CNAME | |
| # Build with preview config that includes staging posts | |
| bundle exec jekyll build --config _config.yml,_config_preview.yml | |
| env: | |
| JEKYLL_ENV: production | |
| - name: Deploy preview | |
| uses: rossjrw/pr-preview-action@v1 | |
| with: | |
| source-dir: ./_site | |
| preview-branch: gh-pages | |
| umbrella-dir: pr-preview |