Add PR documentation preview deployments via GitHub Pages#69
Merged
Conversation
Agent-Logs-Url: https://github.com/multi-objective/moocore/sessions/f9c05a0c-d853-4fdc-83fa-5165964891f0 Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add pull-request documentation previews for multi-objective/moocore
Add PR documentation preview deployments via GitHub Pages
May 8, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #69 +/- ##
==========================================
+ Coverage 76.95% 76.98% +0.02%
==========================================
Files 67 67
Lines 6762 6762
Branches 1330 1330
==========================================
+ Hits 5204 5206 +2
+ Misses 1210 1208 -2
Partials 348 348
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| const marker = '<!-- docs-preview-python-marker -->'; | ||
| const prNumber = context.issue.number; | ||
| const url = `https://multi-objective.github.io/moocore/previews/pr-${prNumber}/python/`; | ||
| const body = `${marker}\n📚 **Python docs preview** for this PR is available at:\n\n${url}`; |
Contributor
There was a problem hiding this comment.
@copilot Change this comment to be:
${marker}\n📚 [**Python docs preview** for this PR](${url})\n\n
Contributor
Author
There was a problem hiding this comment.
Done in d959a86. The comment body now uses the inline link format: 📚 [**Python docs preview** for this PR](${url}).
Agent-Logs-Url: https://github.com/multi-objective/moocore/sessions/5cf05375-6419-4840-8e2f-9818784654ea Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Contributor
|
@copilot Change the comment for R to follow the inline link format of the Python comment. |
Agent-Logs-Url: https://github.com/multi-objective/moocore/sessions/880eae90-1d9e-4294-ba29-1dad881ab38a Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
Contributor
Author
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.
Adds per-PR documentation previews deployed to GitHub Pages under
previews/pr-<N>/randpreviews/pr-<N>/python, with automatic PR comments linking to the previews and cleanup on PR close.R.yml / python.yml (
pkgdown/build-docjobs)pull-requests: writepermission for PR commentinggithub.ref) so per-PR deployments don't block each otherpreviews/pr-${{ github.event.pull_request.number }}/r(or/python); gated to same-repo PRs only viagithub.event.pull_request.head.repo.full_name == github.repositoryactions/github-script@v7with a hidden HTML marker (<!-- docs-preview-r-marker -->/<!-- docs-preview-python-marker -->) to upsert a single comment per workflow on rerunsProduction deployments (
r/andpython/on push tomain) are unchanged.New:
docs-preview-cleanup.ymlTriggered on
pull_request: types: [closed]. Checks outgh-pages, removespreviews/pr-<N>/if present, and pushes. Skipped for fork PRs (which never get previews deployed).Original prompt
Implement pull-request documentation previews for the repository
multi-objective/moocorewhile keeping the documentation build logic in the existing workflows.github/workflows/R.ymland.github/workflows/python.yml.Requirements:
R.ymlandpython.yml; do not introduce a new workflow that duplicates the R or Python docs build steps.r/on push tomainpython/on push tomainpreviews/pr-<PR_NUMBER>/rpreviews/pr-<PR_NUMBER>/pythonmarocchino/sticky-pull-request-commentor other non-official comment actions.actions/github-scriptinstead to create/update a comment via the GitHub API. Prefer a hidden marker strategy so reruns update the same comment instead of creating duplicates.R.ymlandpython.yml.previews/pr-<PR_NUMBER>fromgh-pageswhen a PR is closed.target-foldervalues.gh-pages.Implementation guidance:
.github/workflows/R.yml:JamesIves/github-pages-deploy-action@v4actions/github-scriptcontents: write,pull-requests: writeas needed).github/workflows/python.ymlsimilarly..github/workflows/docs-preview-cleanup.yml, triggered on PR close, to delete the preview directory fromgh-pages.Please create a pull request with these workflow changes.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Study how documentation is built and deployed in @multi-objective/moocore/files/.github/workflows/R.yml and @multi-objective/moocore/files/.github/workflows/python.yml I would like to be able to preview the documentation in pull requests. How to deploy to some temporary location and add the link to the pull request?
Assistant: Use GitHub Pages previews per PR, published into a PR-specific subdirectory, and then comment/update the PR with the URL. In your repo, that fits naturally with the existing
gh-pagesdeployments in both workflows.What you have now:
R.ymlbuilds/deploysr/docstogh-pagesunderr/, but only onpushtomain.python.ymlbuilds/deployspython/doc/_build/html/togh-pagesunderpython/, also only onpushtomain.For PR previews, the simplest pattern is:
pull_request, build docs.previews/pr-123/r/previews/pr-123/python/Recommended URL pattern
https://multi-objective.github.io/moocore/previews/pr-<PR_NUMBER>/python/https://multi-objective.github.io/moocore/previews/pr-<PR_NUMBER>/r/Why this works well:
JamesIves/github-pages-deploy-action@v4Main caveat
pull_requestruns typically do not have permission to push togh-pages.pull_request_targetvery carefully, or switch to another hosting mechanism like artifacts or Cloudflare/Netlify. For security, I recommend starting with same-repo PR previews only.Suggested implementation
1) R docs preview job
Add another deploy step in
.github/workflows/R.ymlfor PRs.Conceptually:
r/previews/pr-${{ github.event.number }}/rExample: