From 8d21d45edd25f7cdfb9f1335bdd71bb5d7eee110 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 28 Nov 2025 14:01:31 +0000 Subject: [PATCH 1/2] Add PR preview deployment action - Add new pr-preview.yml workflow to deploy PR previews using rossjrw/pr-preview-action@v1.6.3 - Update jekyll.yml to use branch-based deployment (peaceiris/actions-gh-pages) instead of artifact-based deployment - Configure main deployment to preserve pr-preview directory - PR previews will be accessible at /pr-preview/pr-{number}/ on the GitHub Pages site --- .github/workflows/jekyll.yml | 32 ++++++++--------------- .github/workflows/pr-preview.yml | 45 ++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/pr-preview.yml diff --git a/.github/workflows/jekyll.yml b/.github/workflows/jekyll.yml index 501686b..00e34e1 100644 --- a/.github/workflows/jekyll.yml +++ b/.github/workflows/jekyll.yml @@ -16,7 +16,7 @@ on: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: - contents: read + contents: write pages: write id-token: write @@ -27,8 +27,8 @@ concurrency: cancel-in-progress: false jobs: - # Build job - build: + # Build and deploy job + build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout @@ -40,26 +40,16 @@ jobs: ruby-version: '3.1' # Not needed with a .ruby-version file bundler-cache: true # runs 'bundle install' and caches installed gems automatically cache-version: 0 # Increment this number if you need to re-download cached gems - - name: Setup Pages - id: pages - uses: actions/configure-pages@v5 - name: Build with Jekyll # Outputs to the './_site' directory by default - run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" + run: bundle exec jekyll build env: JEKYLL_ENV: production - - name: Upload artifact - # Automatically uploads an artifact from the './_site' directory by default - uses: actions/upload-pages-artifact@v3 - - # Deployment job - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site + publish_branch: gh-pages + # Don't remove PR preview files + exclude_assets: 'pr-preview/**' diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml new file mode 100644 index 0000000..f5052b6 --- /dev/null +++ b/.github/workflows/pr-preview.yml @@ -0,0 +1,45 @@ +# Workflow for deploying PR previews to GitHub Pages +name: Deploy PR Preview + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - closed + +# Sets permissions of the GITHUB_TOKEN +permissions: + contents: write + pull-requests: write + +# Prevent concurrent deployments for the same PR +concurrency: preview-${{ github.ref }} + +jobs: + deploy-preview: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + if: github.event.action != 'closed' + + - name: Setup Ruby + uses: ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4 + if: github.event.action != 'closed' + with: + ruby-version: '3.1' + bundler-cache: true + cache-version: 0 + + - name: Build with Jekyll + if: github.event.action != 'closed' + run: bundle exec jekyll build --baseurl "/pr-preview/pr-${{ github.event.number }}" + env: + JEKYLL_ENV: production + + - name: Deploy PR Preview + uses: rossjrw/pr-preview-action@v1.6.3 + with: + source-dir: ./_site/ From 41c78cd9989dfc3043e873d489df3fc370c2270e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 28 Nov 2025 14:18:50 +0000 Subject: [PATCH 2/2] Fix: Use keep_files instead of exclude_assets for PR previews - Change from exclude_assets to keep_files: true in peaceiris/actions-gh-pages - The exclude_assets parameter filters source files, not destination files - keep_files: true preserves existing files in gh-pages branch, including PR preview directories --- .github/workflows/jekyll.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jekyll.yml b/.github/workflows/jekyll.yml index 00e34e1..933239f 100644 --- a/.github/workflows/jekyll.yml +++ b/.github/workflows/jekyll.yml @@ -51,5 +51,5 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./_site publish_branch: gh-pages - # Don't remove PR preview files - exclude_assets: 'pr-preview/**' + # Keep existing files (preserves PR preview directories) + keep_files: true