From fc491808968f9617cd2df5431bbb1311c94a47b4 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 1 Mar 2026 13:21:29 +0000 Subject: [PATCH] ci(hugo): split PR preview deploy and remove actions to fix cleanup The original configuration relied on the implicit "auto" action of rossjrw/pr-preview-action to deploy on open/update and remove on close. However, because the `Build` step is skipped when a PR is closed (`if: github.event.action != 'closed'`), the `public` directory is never created on closed events. As a result, when the unified preview step ran on a PR close, the action failed because it couldn't find the `source-dir: public` directory, which left the preview orphaned on the `gh-pages` branch. This commit explicitly splits the preview step into a `Deploy PR Preview` step and a `Remove PR Preview` step. The removal step sets `source-dir: .` to avoid the missing `public` directory issue and ensures that previews are properly deleted from the `gh-pages` branch when the PR is closed. Co-authored-by: e-minguez <346758+e-minguez@users.noreply.github.com> --- .github/workflows/hugo.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/hugo.yaml b/.github/workflows/hugo.yaml index 8eeec3dc..d3376e5e 100644 --- a/.github/workflows/hugo.yaml +++ b/.github/workflows/hugo.yaml @@ -61,9 +61,19 @@ jobs: force: false - name: Deploy PR Preview - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request' && github.event.action != 'closed' uses: rossjrw/pr-preview-action@v1 with: source-dir: public preview-branch: gh-pages umbrella-dir: pr-preview + action: deploy + + - name: Remove PR Preview + if: github.event_name == 'pull_request' && github.event.action == 'closed' + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: . + preview-branch: gh-pages + umbrella-dir: pr-preview + action: remove