Skip to content

fix: load Dashboard correctly on private and Enterprise GitHub Pages#87

Merged
wasabeef merged 3 commits into
mainfrom
fix/issue-86-pages-base-url
Jul 9, 2026
Merged

fix: load Dashboard correctly on private and Enterprise GitHub Pages#87
wasabeef merged 3 commits into
mainfrom
fix/issue-86-pages-base-url

Conversation

@wasabeef

@wasabeef wasabeef commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

  • resolve the real GitHub Pages base URL from the Pages API (GET /repos/{owner}/{repo}/pageshtml_url) in resolve-pages-target.mjs, using the github.token the composite action already has (pages: write in the generated Dashboard workflow includes read)
  • derive the Astro SITE / BASE values from the resolved URL in build-pages.mjs, keeping the <owner>.github.io/<repo> heuristic as the fallback when the API is unavailable
  • add a pages_base_url action input as an explicit override for both Dashboard builds and PR reports
  • prefer the resolved URL in the PR report's inferDashboardUrl so Open Dashboard ↗ links point at the real Pages domain (the PR Report workflow lacks pages: read by default, so it falls back to the heuristic unless the permission or the input is provided)

Root cause

build-pages.mjs constructed site / base mechanically from the repository name. Private / GHEC Pages sites are served from obfuscated *.pages.github.io domains at the root path, so every stylesheet, script, favicon, and notes/*.json reference pointed at a nonexistent /<repo>/ prefix and 404'd, rendering the dashboard as unstyled HTML. PUBLIC_REPO was pinned in action.yml, leaving callers no workaround.

User impact

Dashboards deployed from private or GitHub Enterprise Cloud repositories load with CSS, JS, and note data applied. Public repositories on the canonical layout are unaffected: when the Pages API resolves the same canonical URL the output is identical, and when the API is unreachable the previous heuristic still applies.

Validation

  • Dashboard tests: 38 passed (9 new: derivePagesPaths root-domain/project-path/fallback/invalid cases, resolvePagesBaseUrl override/API/failure/no-credential cases)
  • pr-report tests: 51 passed (3 new inferDashboardUrl cases with resolved base URLs)
  • Dashboard build, pr-report ncc build
  • CLI build, typecheck, lint, tests: 491 passed
  • CI smoke tests keep exercising the heuristic path (PUBLIC_REPO only, no PAGES_BASE_URL)

Closes #86

🧑💬🤖 Agent Note

Total AI Ratio: ████████ 100%
Model: claude-fable-5

Commit AI Ratio Prompts Files
31f6e8c fix(action): resolve the real Pages URL for Dashboard links and assets █████ 100% 11 action.yml 🤖, cli.js 👤, build-pages.mjs 🤖, resolve-pages-target.mjs 🤖, resolve-pages-target.test.mjs 🤖, index.js 👤, github.ts 🤖, index.test.ts 🤖, index.ts 🤖, report.ts 🤖
048e00d fix(action): normalize resolved Pages URLs before writing step outputs █████ 100% 2 README.md 🤖, resolve-pages-target.mjs 🤖, resolve-pages-target.test.mjs 🤖, index.js 👤, index.ts 🤖
8c70e3b fix(action): bound the PR report Pages API lookup to 10 seconds █████ 100% 1 index.js 👤, index.ts 🤖
💬 Prompts & Responses (10 shown / 14 total)

31f6e8c fix(action): resolve the real Pages URL for Dashboard links and assets

🧑 Prompt

手動で npm publish する方法おしえて

🧑 Prompt

npm -w packages/cli publish --access public 打つだけで

@wasabeef/agentnote
agent-note

両方 publish されるっけ

🧑 Prompt

npm -w packages/cli publish --access public 実行した

🧑 Prompt

private/tmp になってるコマンド見直して

🧑 Prompt

@.github/workflows/release.yml 確認して。同じやり方?

🧑 Prompt

npm publish /tmp/agentnote-alias-1.0.6 --access public --ignore-scripts

実行した

🧑 Prompt

#86

確認して

🧑 Prompt

新しいブランチ切って作業開始

048e00d fix(action): normalize resolved Pages URLs before writing step outputs

🧑 Prompt

8c70e3b fix(action): bound the PR report Pages API lookup to 10 seconds

🧑 Prompt

#87 (comment)

Summary by CodeRabbit

  • New Features

    • Added support for overriding the Dashboard’s GitHub Pages base URL.
    • Dashboard links and asset paths now use the resolved Pages URL when available, improving link accuracy.
  • Bug Fixes

    • Improved URL handling so Dashboard links fall back more safely when a Pages URL is missing or invalid.
    • Added handling for Pages projects hosted at either the site root or a subpath.
  • Tests

    • Expanded coverage for Pages URL resolution and Dashboard link generation scenarios.

Why
Dashboard builds and PR report links derived the Pages URL from the
repository name, assuming the canonical <owner>.github.io/<repo> layout.
Private and Enterprise Pages sites are served from obfuscated
*.pages.github.io domains at the root path, so every asset reference,
notes fetch, and Open Dashboard link pointed at a /<repo>/ prefix that
does not exist and returned 404.

The action now resolves the actual Pages URL from the Pages API with
the workflow token, callers can override it with the new pages_base_url
input, and the previous repository-name layout remains the fallback
when neither source is available.

User impact
Dashboards deployed from private or GitHub Enterprise Cloud
repositories load with styles, scripts, and note data, and PR report
Open Dashboard links point at the real Pages domain. Public
repositories on the canonical layout are unaffected.

Verification
npm test --prefix packages/dashboard (38 passed)
npm run dashboard:build
npm -w packages/pr-report test (51 passed)
npm -w packages/pr-report run build
npm -w packages/cli run build
npm -w packages/cli run typecheck
npm -w packages/cli run lint
npm -w packages/cli test (491 passed)

Release note: Dashboards published from private or Enterprise GitHub Pages now load correctly, and a new pages_base_url action input can override the resolved Pages URL.

Agentnote-Session: 4a6d322d-5afe-45e3-a11b-cf15d0e740a9
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds an optional pages_base_url action input, resolves the actual GitHub Pages URL via the Pages REST API (with override/fallback support) in both the dashboard build workflow and the PR report action, and uses that resolved URL to compute correct asset base paths and dashboard links instead of a repo-name heuristic.

Changes

Pages Base URL Resolution

Layer / File(s) Summary
Action input and environment wiring
action.yml
Adds pages_base_url input and wires it as INPUT_PAGES_BASE_URL/PAGES_BASE_URL into PR Report and Dashboard steps.
Pages target resolution script and API lookup
packages/dashboard/workflow/resolve-pages-target.mjs, packages/dashboard/workflow/resolve-pages-target.test.mjs
Adds resolvePagesBaseUrl to fetch/validate html_url from the GitHub Pages API or an override, updates derivePagesPaths to use it, makes main async with a new pages_base_url output, and adds tests.
Dashboard build script consumes resolved base URL
packages/dashboard/workflow/build-pages.mjs
Replaces inline site/base construction with derivePagesPaths({ pagesBaseUrl, repository }) and updates related constants.
PR report dashboard URL inference from Pages base URL
packages/pr-report/src/github.ts, packages/pr-report/src/index.test.ts
inferDashboardUrl gains a pagesBaseUrl parameter, preferring it (with safe URL parsing) over the repo-URL heuristic, with new tests for root, project-path, and invalid cases.
PR report action resolves and passes pages base URL
packages/pr-report/src/index.ts, packages/pr-report/src/report.ts
Adds resolvePagesBaseUrl(token) in index.ts and wires the resolved value through run()/collectReport, extending CollectReportOptions and its inferDashboardUrl call in report.ts.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Action as GitHub Action (action.yml)
  participant Resolver as resolvePagesBaseUrl
  participant PagesAPI as GitHub Pages API
  participant Consumer as build-pages.mjs / pr-report index.ts

  Action->>Resolver: pages_base_url input / token
  alt override provided and valid
    Resolver-->>Action: return override URL
  else query API
    Resolver->>PagesAPI: GET /repos/{owner}/{repo}/pages
    PagesAPI-->>Resolver: html_url or error
    Resolver-->>Action: return html_url or null
  end
  Action->>Consumer: pass resolved pagesBaseUrl
  Consumer->>Consumer: derive site/base or dashboard_url from pagesBaseUrl
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The Pages URL resolution, override input, and fallback behavior address the reported Dashboard asset 404s and the caller-side workaround requirement.
Out of Scope Changes check ✅ Passed Changes stay focused on Pages URL resolution, dashboard asset paths, and PR report links; no unrelated functionality was added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing Dashboard loading for private and Enterprise GitHub Pages.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-86-pages-base-url

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Re-serialize pages_base_url values through the URL parser so control
characters cannot corrupt the GITHUB_OUTPUT file, and document the new
input in the README.

Release note: skip

Agentnote-Session: 4a6d322d-5afe-45e3-a11b-cf15d0e740a9

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/pr-report/src/index.ts`:
- Around line 150-165: The Octokit Pages lookup in resolvePagesBaseUrl has no
explicit request timeout, so a slow Pages API call can hang the PR report
action. Update the octokit.request call in the Pages metadata fetch path to pass
a request timeout consistent with the dashboard script’s 10-second limit, while
keeping the existing fallback behavior in the catch block unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 85bfde9f-085b-4e22-9e1e-ab79d9709548

📥 Commits

Reviewing files that changed from the base of the PR and between 961953e and 31f6e8c.

⛔ Files ignored due to path filters (2)
  • packages/cli/dist/cli.js is excluded by !**/dist/**, !**/dist/**
  • packages/pr-report/dist/index.js is excluded by !**/dist/**, !**/dist/**
📒 Files selected for processing (8)
  • action.yml
  • packages/dashboard/workflow/build-pages.mjs
  • packages/dashboard/workflow/resolve-pages-target.mjs
  • packages/dashboard/workflow/resolve-pages-target.test.mjs
  • packages/pr-report/src/github.ts
  • packages/pr-report/src/index.test.ts
  • packages/pr-report/src/index.ts
  • packages/pr-report/src/report.ts

Comment thread packages/pr-report/src/index.ts
Octokit requests have no default timeout, so a hung Pages API call
could block the PR report until the job timeout. Pass an abort signal
matching the dashboard script's bound. Addresses CodeRabbit review
feedback on PR #87.

Release note: skip

Agentnote-Session: 4a6d322d-5afe-45e3-a11b-cf15d0e740a9
@wasabeef wasabeef merged commit ffd99cd into main Jul 9, 2026
11 checks passed
@wasabeef wasabeef deleted the fix/issue-86-pages-base-url branch July 9, 2026 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: dashboard assets 404 (unstyled page) on private/Enterprise Pages — base is derived from repo name instead of the actual Pages URL

1 participant