Skip to content

ci: publish PR previews#7

Draft
spike1236 wants to merge 3 commits into
mainfrom
ci-pr-previews
Draft

ci: publish PR previews#7
spike1236 wants to merge 3 commits into
mainfrom
ci-pr-previews

Conversation

@spike1236

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an automated GitHub Pages-based PR preview system for the generated Jekyll documentation, alongside adjustments to the existing publish workflow to maintain a “Pages state” branch that includes both the main site and per-PR preview subdirectories.

Changes:

  • Build a PR-specific Jekyll site in verify.yml for pull_request runs and upload it as an artifact.
  • Update publish.yml to publish the main site into gh-pages while preserving numeric preview directories, and to deploy PR previews by copying the preview artifact into gh-pages/<pr-number>/.
  • Add delete-preview.yml to remove gh-pages/<pr-number>/ when a PR is closed and redeploy Pages.

Reviewed changes

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

File Description
.github/workflows/verify.yml Builds and uploads a per-PR Jekyll preview artifact with a PR-scoped baseurl.
.github/workflows/publish.yml Publishes main docs to a gh-pages “state” branch and deploys PR previews from artifacts.
.github/workflows/delete-preview.yml Deletes preview content for closed PRs from the Pages state and redeploys.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +240 to +246
mapfile -t preview_dirs < <(find public -mindepth 1 -maxdepth 1 -type d -printf '%f\n' | sort)
if [ "${#preview_dirs[@]}" -ne 1 ]; then
printf 'Expected exactly one PR preview artifact, found %s.\n' "${#preview_dirs[@]}"
printf '%s\n' "${preview_dirs[@]}"
exit 1
fi
pr_number="${preview_dirs[0]}"
Comment on lines +296 to +320
set -euo pipefail
pr_number="${{ steps.preview.outputs.number }}"

if [ "$SHOULD_PUBLISH" = "true" ]; then
rm -rf "_pages/$pr_number"
mkdir -p "_pages/$pr_number"
cp -a "public/$pr_number/." "_pages/$pr_number/"
commit_message="Preview for #$pr_number ($HEAD_SHA) at ${{ steps.preview.outputs.url }}"
elif [ "$SHOULD_DELETE" = "true" ]; then
if [ ! -d "_pages/$pr_number" ]; then
echo "PR #$pr_number is $PR_STATE and no preview directory exists."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
rm -rf "_pages/$pr_number"
commit_message="Delete preview for #$pr_number"
else
echo "Skipping stale preview for #$pr_number; PR head is $PR_HEAD_SHA and workflow head is $HEAD_SHA."
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi

touch _pages/.nojekyll
git -C _pages add -A "$pr_number" .nojekyll
if git -C _pages diff --cached --quiet; then
Comment on lines +188 to +195
- name: Configure PR preview base URL
if: github.event_name == 'pull_request'
shell: bash
run: |
{
echo 'url: https://lib.cp-algorithms.com'
echo 'baseurl: "/${{ github.event.pull_request.number }}"'
} >> _jekyll/_config.yml
@spike1236 spike1236 marked this pull request as draft May 5, 2026 06:06
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