ci: publish PR previews#7
Draft
spike1236 wants to merge 3 commits into
Draft
Conversation
There was a problem hiding this comment.
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.ymlforpull_requestruns and upload it as an artifact. - Update
publish.ymlto publish the main site intogh-pageswhile preserving numeric preview directories, and to deploy PR previews by copying the preview artifact intogh-pages/<pr-number>/. - Add
delete-preview.ymlto removegh-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 |
# Conflicts: # .github/workflows/verify.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.