Point PR-preview GitHub links at the PR (closes #136)#137
Conversation
On PR-preview builds, the navbar GitHub icon now opens the PR conversation page and quarto's "Edit this page" / "View source" actions land on the PR head branch instead of UCD-SERG/rpt main. Non-PR builds are untouched. docs.yaml gains a `yq` step before `altdoc::render_docs()` that rewrites three keys in altdoc/quarto_website.yml: `website.repo-url`, `website.repo-branch`, and the `website.navbar.right[icon == github].href`. Sourced from `github.event.pull_request.head.repo.full_name`, `head.ref`, and `html_url`. yq is preinstalled on ubuntu-latest. A comment in altdoc/quarto_website.yml flags that those three keys are mutated in PR builds, so the in-place rewrite isn't a surprise to anyone reading the YAML cold. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the documentation workflow so PR preview builds point Quarto repository links at the pull request’s head repository/branch and the navbar GitHub icon at the PR conversation.
Changes:
- Adds a PR-only workflow step that rewrites Quarto repo link settings before rendering docs.
- Documents the CI mutation behavior in
altdoc/quarto_website.yml.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
.github/workflows/docs.yaml |
Adds the PR-preview yq rewrite step before altdoc::render_docs(). |
altdoc/quarto_website.yml |
Adds a comment explaining CI-time rewriting of GitHub link-related settings. |
| # `repo-url`, `repo-branch`, and the navbar github icon's `href` below are | ||
| # rewritten in-place by .github/workflows/docs.yaml on PR-preview builds, so | ||
| # "Edit this page" / "View source" / the navbar GitHub link point at the PR | ||
| # branch and the PR conversation page instead of the main repo. |
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
|
@claude apply changes based on the comments in this thread then review and then revise |
|
Claude finished @d-morrison's task in 1m 32s —— View job Applied review feedback + PR reviewTasks completed:
Change appliedThe comment in # On PR-preview builds, .github/workflows/docs.yaml rewrites `repo-url` and
# the navbar GitHub icon's `href` below, and inserts `repo-branch` (absent
# here; added dynamically), so "Edit this page" / "View source" / the navbar
# GitHub link point at the PR branch and PR conversation page, not main.Code review
|
The previous comment said all three keys are "rewritten in-place", but `repo-branch` does not exist in this file — the workflow inserts it dynamically on PR-preview builds. Co-authored-by: Douglas Ezra Morrison <d-morrison@users.noreply.github.com>
If the navbar selector (`.website.navbar.right[] | select(.icon == "github")`) ever fails to match — e.g. because someone renames the entry or the version dropdown script later widens its scope — the yq edit silently no-ops and the preview site keeps pointing at main. Read the three values back after the rewrites and fail the workflow if any of them isn't what we expected, so the regression surfaces immediately in CI rather than as a confusing user experience on the preview. Also added a comment pinning the step ordering (must run after the version dropdown generator) to head off subtle future breakage. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two issues from round 2: - `yq -i '.website.X = ...'` will *create* X if .website itself has been renamed or restructured, so the postcondition check would happily read back the value we just wrote into a key quarto ignores. Add a precondition pass with `yq -e` that fails the workflow if either `.website.repo-url` or the navbar `icon: github` entry is missing before we attempt to rewrite anything. - Replaced the `[ A ] || [ B ] || [ C ]` line-continuation chain with a single `[[ A || B || C ]]` to remove the trailing-whitespace footgun. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Closes #136.
Summary
docs.yaml: on PR builds, runyqagainstaltdoc/quarto_website.ymlbeforealtdoc::render_docs()to rewrite three keys:website.repo-url→https://github.com/<head_repo_full_name>website.repo-branch→<head_ref>(so quarto's "Edit this page" / "View source" land on the right file in the right branch)website.navbar.right[icon == "github"].href→<pull_request.html_url>(so the navbar GitHub icon opens the PR conversation page)altdoc/quarto_website.yml: add a short comment next to the three keys so it's not a surprise that they get mutated in CI.yqis preinstalled on ubuntu-latest, so no extra setup step needed.Test plan
https://github.com/d-morrison/rpt/pull/<this PR#>.https://github.com/<head_repo>/edit/<head_ref>/..., not main.mainshould produce a site whose navbar GitHub icon points at the repo root ($ALTDOC_PACKAGE_URL_GITHUBsubstituted by altdoc), confirming non-PR builds were left untouched.🤖 Generated with Claude Code