Skip to content

ci(.github/workflows): deep-link docs preview to first changed page#24832

Merged
david-fraley merged 4 commits into
mainfrom
dfraley/docs-preview-deeplink
Apr 30, 2026
Merged

ci(.github/workflows): deep-link docs preview to first changed page#24832
david-fraley merged 4 commits into
mainfrom
dfraley/docs-preview-deeplink

Conversation

@david-fraley
Copy link
Copy Markdown
Collaborator

@david-fraley david-fraley commented Apr 29, 2026

Description

The docs-preview workflow currently links to the docs root for the
branch (e.g. https://coder.com/docs/@<branch>), which forces
reviewers to navigate to the page they actually changed. This makes
the comment deep-link to the first added, modified, or renamed
Markdown page under docs/ instead.

If a PR only deletes Markdown files (or only changes non-Markdown
files such as images or manifest.json), the workflow now exits
without commenting.

How the page is selected

No AI/LLM is involved. The workflow uses a deterministic shell
pipeline:

  1. gh api repos/${REPO}/pulls/${PR_NUMBER}/files to list changed
    files with their status and filename.
  2. jq filter select(.status != "removed") to drop deletions.
  3. grep -E '^docs/.*\.md$' | head -n 1 to keep the first Markdown
    file under docs/.
  4. A shell case block maps that repo path to a docs-site URL
    suffix.
  5. gh pr comment posts the rendered URL.

Path mapping

Repo path Preview URL suffix
docs/README.md (none — branch root)
docs/install/index.md /install
docs/ai-coder/tasks.md /ai-coder/tasks
docs/about/contributing/CONTRIBUTING.md /about/contributing/CONTRIBUTING

Proof

Re-running the new logic against #24831
(which only modifies docs/ai-coder/tasks.md) produces:

https://coder.com/docs/@dfraley%2Fcodagt-157-tasks-deprecation-header/ai-coder/tasks

Versus today's link, which lands on the docs index for the branch:

https://coder.com/docs/@dfraley%2Fcodagt-157-tasks-deprecation-header

A unit-style smoke test of the path-mapping shell logic was run
locally and all cases pass:

Local test output
PASS: docs/README.md                                               -> ''
PASS: docs/install/index.md                                        -> install
PASS: docs/ai-coder/tasks.md                                       -> ai-coder/tasks
PASS: docs/about/contributing/CONTRIBUTING.md                      -> about/contributing/CONTRIBUTING
PASS: docs/admin/templates/index.md                                -> admin/templates
PASS: docs/admin/templates/managing-templates/index.md             -> admin/templates/managing-templates
PASS: docs/install/cloud/index.md                                  -> install/cloud
PASS: docs/admin/templates/extending-templates/icons.md            -> admin/templates/extending-templates/icons
PASS: docs/tutorials/quickstart.md                                 -> tutorials/quickstart

actionlint (with shellcheck integration) is clean.


Note

AI-assisted: this PR was authored by Coder Agents on @david-fraley's
behalf, per AI_CONTRIBUTING.md.

…hanged page

Make the docs-preview comment link directly to the first added,
modified, or renamed Markdown page under docs/ instead of the
docs root for the branch.

If a PR only deletes Markdown files (or only changes non-Markdown
files such as images or manifest.json), no comment is posted.
@david-fraley david-fraley marked this pull request as ready for review April 29, 2026 21:20
@jdomeracki-coder
Copy link
Copy Markdown
Contributor

/coder-agents-review

Copy link
Copy Markdown
Contributor

@coder-agents-review coder-agents-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-scoped improvement. The path-mapping logic is correct across all 452 current doc files. The PR description is thorough: it shows the problem, the mechanism, proof against a real PR, and local test output. Commit message and scope are proportional.

Severity count: 4 P3, 1 Nit, 1 Note.

DEREM-1 through DEREM-2 are tightly related: separating the gh api call from the grep | head pipeline fixes both (API errors propagate, log message becomes accurate). DEREM-4 proposes a structural simplification of the mapper that was verified against all test cases plus adversarial inputs.

Pariston ran a differential diagnosis of four problem framings and concluded the chosen approach is proportional. Mafu-san and Chopper found no issues beyond DEREM-1. Mafuuu confirmed all five documented contracts are kept by the implementation.

As Hisoka put it: "the comment names only the least interesting" of the three failure modes sharing that || true.

🤖 This review was automatically generated with Coder Agents.

Comment thread .github/workflows/docs-preview.yaml Outdated
Comment thread .github/workflows/docs-preview.yaml
Comment thread .github/workflows/docs-preview.yaml
Comment thread .github/workflows/docs-preview.yaml
Comment thread .github/workflows/docs-preview.yaml
Comment thread .github/workflows/docs-preview.yaml
jdomeracki-coder and others added 2 commits April 30, 2026 08:31
- Separate gh-api call from grep/head pipeline so API failures
  (network, auth, rate-limit) propagate instead of being silently
  swallowed by `|| true` (DEREM-1, DEREM-2).
- Commit path-mapper regression tests covering all five case
  branches plus edge cases for deeper nesting (DEREM-3).
@david-fraley david-fraley enabled auto-merge (squash) April 30, 2026 19:58
shfmt enforces tab indentation by default in CI; the test file
landed with two-space indents and broke the fmt job. Run
shfmt -w to bring it into compliance.
@david-fraley david-fraley changed the title ci(.github/workflows/docs-preview.yaml): deep-link preview to first changed page ci(.github/workflows): deep-link docs preview to first changed page Apr 30, 2026
@david-fraley david-fraley merged commit 27b527d into main Apr 30, 2026
32 of 33 checks passed
@david-fraley david-fraley deleted the dfraley/docs-preview-deeplink branch April 30, 2026 20:11
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants