Skip to content

Fix fork deployment links#10

Merged
nschimme merged 2 commits intoMUME:masterfrom
nschimme:fix-fork-deployment-links-9519169759991546476
May 5, 2026
Merged

Fix fork deployment links#10
nschimme merged 2 commits intoMUME:masterfrom
nschimme:fix-fork-deployment-links-9519169759991546476

Conversation

@nschimme
Copy link
Copy Markdown
Contributor

@nschimme nschimme commented May 5, 2026

Summary by Sourcery

Adjust preview and deployment URL handling to work correctly for forks and GitHub Pages setups while restricting custom domain usage to the main repository.

Enhancements:

  • Restrict use of CNAME for base URL detection and deployment to the primary repository owner only.
  • Improve VITE_HOSTNAME resolution with fallbacks that correctly handle forks, main repo without CNAME, and GitHub Pages repositories.
  • Adjust PR preview URL construction in deployment workflow to derive correct base URLs for forks and non-CNAME setups.
  • Remove automated PR build status comment posting from the preview workflow to simplify CI output.

nschimme added 2 commits May 5, 2026 14:12
Modified GitHub workflows and environment scripts to conditionally use
the root CNAME file only when the repository owner is 'mume'.
This ensures that forked repositories correctly generate deployment links
pointing to their own GitHub Pages domain (<username>.github.io/<repo>)
rather than the official MUME domain.

Specifically:
- Updated .github/workflows/pr-preview.yml to use owner-aware host detection.
- Updated .github/workflows/deploy.yml to conditionally copy CNAME and set deployment URLs.
- Updated scripts/ci-env.sh to dynamically resolve VITE_HOSTNAME based on repo ownership.
…ndant PR comments

This commit ensures that forked repositories correctly use their GitHub Pages URL
(<username>.github.io/<repo>) for deployments and PR previews, rather than the
official MUME domain.

Key changes:
- Updated `.github/workflows/pr-preview.yml` and `.github/workflows/deploy.yml`
  to only use the `CNAME` file and the `docs.mume.org` domain if the repository
  owner is 'mume'.
- Aligned URL construction logic across workflows and `scripts/ci-env.sh` for consistency.
- Removed the redundant "Build ready" bot comment from PRs in favor of the native
  GitHub deployment status button.
- Improved environment variable defaulting in `scripts/ci-env.sh` for better robustness.
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 5, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts preview and deploy URL handling to work correctly for the main repo, forks, and GitHub Pages repos, and removes the PR build-status comment step.

Flow diagram for preview base URL determination in PR workflows

flowchart TD
  subgraph PR_Preview_Workflow
    A1[Start Determine Base URL Prefix] --> B1{CNAME exists AND repository_owner = mume}
    B1 -->|yes| C1[Set prefix = / and host = CNAME]
    B1 -->|no| D1{repository.name = repository_owner.github.io}
    D1 -->|yes| E1[Set prefix = / and host = repository.name]
    D1 -->|no| F1[Set prefix = /repository.name/ and host = repository_owner.github.io]
  end

  subgraph Deploy_Workflow
    A2[After build] --> B2{CNAME exists AND repository_owner = mume}
    B2 -->|yes| C2[Copy CNAME into dist/CNAME]
    B2 -->|no| D2[Do not copy CNAME]

    E2[Set default base = https://owner.github.io] --> F2{CNAME exists AND owner = mume}
    F2 -->|yes| G2[Read domain from CNAME and set base = https://domain]
    F2 -->|no| H2[Set repo = context.repo.repo]
    H2 --> I2{repo != owner.github.io}
    I2 -->|yes| J2[Set base = base + /repo]
    I2 -->|no| K2[Keep base unchanged]

    G2 --> L2[Construct preview URL = base + /pr-PR_NUMBER/]
    J2 --> L2
    K2 --> L2
  end
Loading

File-Level Changes

Change Details Files
Tighten CNAME-based URL logic so it only applies to the main mume/docs repo and not forks.
  • Gate the CNAME-based base URL prefix in the PR preview workflow on github.repository_owner being mume
  • Gate copying CNAME into the build output in the deploy workflow on github.repository_owner being mume
.github/workflows/pr-preview.yml
.github/workflows/deploy.yml
Improve VITE_HOSTNAME resolution to support forks, GitHub Pages repos, and the main docs repo without relying solely on CNAME.
  • Restrict CNAME-based VITE_HOSTNAME to when GITHUB_REPOSITORY_OWNER is mume
  • Add logic to derive OWNER and REPO from GitHub environment variables with sensible defaults
  • Compute VITE_HOSTNAME differently for mume/docs, owner.github.io repos, and other repos using owner.github.io/repo form
scripts/ci-env.sh
Simplify PR preview notifications by removing the GitHub Actions comment step and adjusting preview URL construction for forks.
  • Remove the github-script step that posts or updates a PR comment with the preview URL
  • Update deploy workflow preview URL base calculation to ignore CNAME for non-mume owners and to append the repo name for non-owner.github.io repos
.github/workflows/pr-preview.yml
.github/workflows/deploy.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Build ready

The build for this PR has been completed successfully. A live preview will be available at: https://docs.mume.org/pr-10/

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • There is now duplicated and slightly divergent logic for deriving the preview/base hostname (in scripts/ci-env.sh and the deploy.yml GitHub Script step); consider consolidating this into a single source of truth or at least mirroring the same owner/repo/CNAME handling to avoid subtle drift between environments.
  • The hardcoded checks for mume (both in bash and workflow YAML) make this logic less reusable; you could centralize the canonical owner name in a single environment variable or workflow input so forks or future owner changes don’t require touching multiple conditionals.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There is now duplicated and slightly divergent logic for deriving the preview/base hostname (in `scripts/ci-env.sh` and the `deploy.yml` GitHub Script step); consider consolidating this into a single source of truth or at least mirroring the same owner/repo/CNAME handling to avoid subtle drift between environments.
- The hardcoded checks for `mume` (both in bash and workflow YAML) make this logic less reusable; you could centralize the canonical owner name in a single environment variable or workflow input so forks or future owner changes don’t require touching multiple conditionals.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@nschimme nschimme merged commit f207ed6 into MUME:master May 5, 2026
3 checks passed
@nschimme nschimme deleted the fix-fork-deployment-links-9519169759991546476 branch May 5, 2026 14:25
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.

1 participant