Skip to content

ci(pages): support main deploy with isolated PR previews#6

Merged
wintermuted merged 5 commits into
mainfrom
feat/pages-main-and-pr-previews
May 5, 2026
Merged

ci(pages): support main deploy with isolated PR previews#6
wintermuted merged 5 commits into
mainfrom
feat/pages-main-and-pr-previews

Conversation

@wintermuted
Copy link
Copy Markdown
Owner

Summary

  • keep production deploy at Pages root while preserving preview content
  • deploy pull request previews to previews/pr-/showcase/
  • add cleanup workflow to remove preview directories when PRs close
  • stop auto-toggling Pages source in workflow; use stable gh-pages branch source

Why

This prevents PR preview deploys from overwriting the production site and allows both to coexist.

Notes

Set repository Pages source to Deploy from a branch -> gh-pages -> /(root).

Verification

  • workflow logic reviewed for push, pull_request, and pull_request closed events
  • preview URL now includes PR-numbered subpath

Copilot AI review requested due to automatic review settings May 5, 2026 02:54
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🚀 PR Preview deployed!

📖 Open showcase preview

ℹ️ Production remains at root Pages URL. This preview is isolated to PR #6.

Run 25355336236 — commit 8efc602

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the GitHub Pages deployment strategy for the UI-theme showcase so that main continues to publish to the Pages root while pull requests publish isolated previews under a PR-numbered subdirectory, with a companion workflow to clean up previews when PRs close.

Changes:

  • Deploy main builds to the gh-pages root while preserving previews/ content; deploy PR builds to previews/pr-<number>/.
  • Add path filters so the deploy workflow only runs when relevant files change.
  • Add a cleanup workflow to remove previews/pr-<number>/ when a PR is closed.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
.github/workflows/deploy-showcase-pages.yml Splits prod vs PR preview publish locations on gh-pages, adds path filters, updates preview URL/comment text.
.github/workflows/cleanup-showcase-preview.yml Adds a PR-close workflow intended to delete the corresponding preview directory from gh-pages.

Comment on lines +19 to +27
- name: Remove preview directory from gh-pages
run: |
if ! git ls-remote --exit-code --heads origin gh-pages > /dev/null 2>&1; then
echo "gh-pages does not exist; nothing to clean."
exit 0
fi

git fetch origin gh-pages
git worktree add --detach ./gh-pages-out FETCH_HEAD
Comment on lines 14 to +21
pull_request:
branches:
- main
paths:
- "showcase/**"
- "styles/**"
- "index.css"
- ".github/workflows/deploy-showcase-pages.yml"
Comment on lines +3 to +7
on:
pull_request:
types:
- closed

if ! git diff --staged --quiet; then
git commit -m "Deploy: ${{ github.sha }}"
git commit -m "Deploy (${{ github.event_name }}): ${{ github.sha }}"
git push --force origin HEAD:refs/heads/gh-pages
Comment on lines +41 to +45
git add -A
if ! git diff --staged --quiet; then
git commit -m "Cleanup preview for PR #${{ github.event.pull_request.number }}"
git push --force origin HEAD:refs/heads/gh-pages
fi
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b5bba78d7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +21 to +23
if ! git ls-remote --exit-code --heads origin gh-pages > /dev/null 2>&1; then
echo "gh-pages does not exist; nothing to clean."
exit 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Checkout repo before running cleanup git commands

This cleanup job runs git ls-remote --heads origin gh-pages without first checking out the repository, so no origin remote is configured in the runner workspace. In that state the command fails and the script takes the "gh-pages does not exist" early-exit path, which means closed PR previews are never removed. Add an actions/checkout step (or use an explicit repository URL and initialize a repo) before invoking these git operations.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🚀 PR Preview deployed!

📖 Open showcase preview

ℹ️ Production remains at root Pages URL. This preview is isolated to PR #6.

Run 25355423043 — commit 28403b3

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🚀 PR Preview deployed!

📖 Open showcase preview

ℹ️ Production remains at root Pages URL. This preview is isolated to PR #6.

Run 25355652202 — commit 93518ba

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🚀 PR Preview deployed!

📖 Open showcase preview

ℹ️ Production remains at root Pages URL. This preview is isolated to PR #6.

Run 25355679870 — commit 133a5f3

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🚀 PR Preview deployed!

📖 Open showcase preview

ℹ️ Production remains at root Pages URL. This preview is isolated to PR #6.

Run 25355850408 — commit 4b5684c

@wintermuted wintermuted merged commit bd43f8d into main May 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants