Skip to content

PR previews: GitHub links should point at PR conversation / head branch #136

@d-morrison

Description

@d-morrison

The PR-preview site that rossjrw/pr-preview-action deploys under /pr-preview/pr-<N>/ is built from altdoc/quarto_website.yml. Three knobs decide where its GitHub links go, and right now all three point at the main repo / main branch:

  • repo-url: (hardcoded to https://github.com/UCD-SERG/rpt) — drives quarto's repo-actions: [edit, source, issue] ("Edit this page", "View source").
  • repo-branch: (not set, so quarto defaults to main) — the branch portion of those URLs.
  • The navbar github icon's href: ($ALTDOC_PACKAGE_URL_GITHUB, substituted by altdoc from URL in DESCRIPTION) — just goes to the repo root.

For PR previews these should instead point at the PR/branch under review, so reviewers can click through to the right place. Proposed mapping:

  • repo-url:https://github.com/<head_repo_full_name>
  • repo-branch:<head_ref> (so "Edit this page" / "View source" lands on the right file in the right branch)
  • Navbar GitHub icon href:https://github.com/<base_repo>/pull/<PR#> (the PR conversation page)

docs.yaml already has github.event.pull_request.head.repo.full_name, head.ref, and number available on PR builds. The change is a small step that rewrites those three values in altdoc/quarto_website.yml on disk before altdoc::render_docs() runs; non-PR builds leave the file untouched.

Tradeoff: this is an in-place CI rewrite, not a clean templating system — the template now has "this file is mutated in PR builds" semantics that someone reading the YAML cold won't see. A comment in quarto_website.yml next to the affected keys is enough to document it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions