From 60dec5cdfb7ce6b20210855d7a19a11b34a7ba79 Mon Sep 17 00:00:00 2001 From: gilgamezh Date: Sun, 7 Dec 2025 19:23:33 +0100 Subject: [PATCH 1/9] add pr build check for pelican --- .github/workflows/pelican-gh-pages.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/pelican-gh-pages.yml b/.github/workflows/pelican-gh-pages.yml index 98b244e..af6ea6c 100644 --- a/.github/workflows/pelican-gh-pages.yml +++ b/.github/workflows/pelican-gh-pages.yml @@ -3,6 +3,8 @@ name: Deploy to GitHub Pages on: push: branches: [master] + pull_request: + branches: [master] workflow_dispatch: concurrency: @@ -26,6 +28,13 @@ jobs: uses: actions/setup-python@v6 with: python-version: ${{ env.PYTHON_VERSION }} + - name: Cache pip + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- - name: Install dependencies run: | python -m pip install --upgrade pip @@ -34,12 +43,14 @@ jobs: run: | make prod - name: Upload Pages artifact + if: github.event_name == 'push' uses: actions/upload-pages-artifact@v3 with: path: output deploy: needs: build + if: github.event_name == 'push' && github.ref == 'refs/heads/master' runs-on: ubuntu-latest environment: name: github-pages From 2d460462fe8b0e7d3726d66d74269ba1a180dcc9 Mon Sep 17 00:00:00 2001 From: gilgamezh Date: Sun, 7 Dec 2025 19:24:59 +0100 Subject: [PATCH 2/9] add preview artifact for pr builds --- .github/workflows/pelican-gh-pages.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pelican-gh-pages.yml b/.github/workflows/pelican-gh-pages.yml index af6ea6c..11ad6c0 100644 --- a/.github/workflows/pelican-gh-pages.yml +++ b/.github/workflows/pelican-gh-pages.yml @@ -42,6 +42,12 @@ jobs: - name: Build site for production run: | make prod + - name: Upload preview artifact + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v3 + with: + name: site-preview + path: output - name: Upload Pages artifact if: github.event_name == 'push' uses: actions/upload-pages-artifact@v3 From c5d1e26e662da324c0885ad3e67f88320abd7d7b Mon Sep 17 00:00:00 2001 From: gilgamezh Date: Sun, 7 Dec 2025 19:27:03 +0100 Subject: [PATCH 3/9] fix permissions for pr builds --- .github/workflows/pelican-gh-pages.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pelican-gh-pages.yml b/.github/workflows/pelican-gh-pages.yml index 11ad6c0..98196f6 100644 --- a/.github/workflows/pelican-gh-pages.yml +++ b/.github/workflows/pelican-gh-pages.yml @@ -13,8 +13,6 @@ concurrency: permissions: contents: read - pages: write - id-token: write env: PYTHON_VERSION: '3.11' @@ -22,6 +20,8 @@ env: jobs: build: runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@v5 - name: Set up Python @@ -58,6 +58,10 @@ jobs: needs: build if: github.event_name == 'push' && github.ref == 'refs/heads/master' runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} From 03cf92b5a5e81d3241f7ee4114683532de02ec71 Mon Sep 17 00:00:00 2001 From: gilgamezh Date: Sun, 7 Dec 2025 19:28:14 +0100 Subject: [PATCH 4/9] bump artifact actions to v4 --- .github/workflows/pelican-gh-pages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pelican-gh-pages.yml b/.github/workflows/pelican-gh-pages.yml index 98196f6..760e62d 100644 --- a/.github/workflows/pelican-gh-pages.yml +++ b/.github/workflows/pelican-gh-pages.yml @@ -44,13 +44,13 @@ jobs: make prod - name: Upload preview artifact if: github.event_name == 'pull_request' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: site-preview path: output - name: Upload Pages artifact if: github.event_name == 'push' - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v4 with: path: output From 99ae1d95c629d099edd03f6621f90ad9f9531d7b Mon Sep 17 00:00:00 2001 From: gilgamezh Date: Sun, 7 Dec 2025 19:36:08 +0100 Subject: [PATCH 5/9] add pr preview deploy via github pages --- .github/workflows/pelican-gh-pages.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pelican-gh-pages.yml b/.github/workflows/pelican-gh-pages.yml index 760e62d..326ec60 100644 --- a/.github/workflows/pelican-gh-pages.yml +++ b/.github/workflows/pelican-gh-pages.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: concurrency: - group: pages + group: pages-${{ github.head_ref || github.ref }} cancel-in-progress: true permissions: @@ -49,7 +49,6 @@ jobs: name: site-preview path: output - name: Upload Pages artifact - if: github.event_name == 'push' uses: actions/upload-pages-artifact@v4 with: path: output @@ -69,3 +68,19 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4 + + deploy_preview: + needs: build + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false + runs-on: ubuntu-latest + permissions: + contents: read + pages: write + id-token: write + environment: + name: pr-${{ github.event.number }} + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy PR preview to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 From 40dc3dfdbfc6f19fedb40ee4335f23e52355b66d Mon Sep 17 00:00:00 2001 From: gilgamezh Date: Sun, 7 Dec 2025 19:39:57 +0100 Subject: [PATCH 6/9] enable pages preview url for prs --- .github/workflows/pelican-gh-pages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pelican-gh-pages.yml b/.github/workflows/pelican-gh-pages.yml index 326ec60..c6aabc0 100644 --- a/.github/workflows/pelican-gh-pages.yml +++ b/.github/workflows/pelican-gh-pages.yml @@ -84,3 +84,5 @@ jobs: - name: Deploy PR preview to GitHub Pages id: deployment uses: actions/deploy-pages@v4 + with: + preview: true From 57f73ddcc405d6f5527395fabf16f199743d5862 Mon Sep 17 00:00:00 2001 From: gilgamezh Date: Sun, 7 Dec 2025 19:41:46 +0100 Subject: [PATCH 7/9] show preview url in pr job summary --- .github/workflows/pelican-gh-pages.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pelican-gh-pages.yml b/.github/workflows/pelican-gh-pages.yml index c6aabc0..b50673f 100644 --- a/.github/workflows/pelican-gh-pages.yml +++ b/.github/workflows/pelican-gh-pages.yml @@ -86,3 +86,6 @@ jobs: uses: actions/deploy-pages@v4 with: preview: true + - name: Publish preview URL + run: | + echo "Preview URL: ${{ steps.deployment.outputs.page_url }}" >> $GITHUB_STEP_SUMMARY From dfd2911748a2705f12bbc0ef55ea34d8b694dfe5 Mon Sep 17 00:00:00 2001 From: gilgamezh Date: Sun, 7 Dec 2025 19:44:11 +0100 Subject: [PATCH 8/9] strip cname for pr previews and show url --- .github/workflows/pelican-gh-pages.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pelican-gh-pages.yml b/.github/workflows/pelican-gh-pages.yml index b50673f..2ae942b 100644 --- a/.github/workflows/pelican-gh-pages.yml +++ b/.github/workflows/pelican-gh-pages.yml @@ -42,6 +42,9 @@ jobs: - name: Build site for production run: | make prod + - name: Remove custom domain for PR previews + if: github.event_name == 'pull_request' + run: rm -f output/CNAME - name: Upload preview artifact if: github.event_name == 'pull_request' uses: actions/upload-artifact@v4 From bba558bb7224f094a877488d6e56b3202425880b Mon Sep 17 00:00:00 2001 From: gilgamezh Date: Sun, 7 Dec 2025 19:47:14 +0100 Subject: [PATCH 9/9] comment pr preview artifact link --- .github/workflows/pelican-gh-pages.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/pelican-gh-pages.yml b/.github/workflows/pelican-gh-pages.yml index 2ae942b..450415e 100644 --- a/.github/workflows/pelican-gh-pages.yml +++ b/.github/workflows/pelican-gh-pages.yml @@ -22,6 +22,7 @@ jobs: runs-on: ubuntu-latest permissions: contents: read + pull-requests: write steps: - uses: actions/checkout@v5 - name: Set up Python @@ -51,6 +52,20 @@ jobs: with: name: site-preview path: output + - name: Comment preview link + if: github.event_name == 'pull_request' + uses: actions/github-script@v7 + env: + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + with: + script: | + const body = `Preview build ready: [download site-preview artifact](${process.env.RUN_URL})`; + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body + }); - name: Upload Pages artifact uses: actions/upload-pages-artifact@v4 with: