Repository navigation
Enable docs previews for fork PRs via unprivileged build + workflow_run deploy - #87
Conversation
Co-authored-by: MLopez-Ibanez <2620021+MLopez-Ibanez@users.noreply.github.com>
workflow_run deploy
|
@copilot How do you make use of the repository environments docs-preview (no rules) and docs-preview-fork (required reviewers: maintainers). |
They aren't used. Those environments were in my earlier design sketch, but the committed environment: ${{ github.event.workflow_run.head_repository.full_name != github.repository && 'docs-preview-fork' || 'docs-preview' }}Fork runs then wait for the maintainers' approval, and same-repo runs go straight through ( |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #87 +/- ##
==========================================
+ Coverage 77.74% 77.86% +0.11%
==========================================
Files 71 71
Lines 7577 7577
Branches 1476 1476
==========================================
+ Hits 5891 5900 +9
+ Misses 1315 1304 -11
- Partials 371 373 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
@copilot The new workflow docs-preview-deploy.yml did not run and there is no comment showing the previews for R and Python. |
This is expected and not a bug in the workflow. The deploy and the preview comments will only appear after this PR is merged, on PRs opened or updated after that. I can't test it end to end before the merge. If you want to test it first, you could push the new workflow to |
PR docs previews were skipped for fork PRs. The
pull_requesttoken is read-only for forks, so the deploy and comment steps were gated onhead.repo.full_name == github.repository. This PR splits build from deploy so forks get previews without giving PR code a write token.Build (
python.yml,R.yml)pull_requesttrigger is unchanged, so PR code still runs unprivileged.docs-preview-pythonordocs-preview-r, each holdingsite/andpr-number. The artifact is kept for 3 days.pull-requests: writeis removed.mainon push is unchanged.Deploy (
docs-preview-deploy.yml, new)workflow_runforPythonandR, so it runs from the default branch with a write token.pull_requestand its conclusion issuccess.site/index.htmlexists, and that there are no symlinks.previews/pr-<n>/{python,r}and posts or updates the PR comment, with one marker each for Python and R.gh-pages-deployconcurrency group withcancel-in-progress: false. This keeps the Python and R pushes togh-pagesfrom racing.Cleanup (
docs-preview-cleanup.yml)pull_requesttopull_request_target, which has a write token for fork PRs, and drops the same-repoif.gh-pages, never PR code.env:instead of being interpolated into the script.Review notes
workflow_runworkflows only run from the default branch, so fork previews start working after this is merged.