Skip to content

fix: correct sitemap.xml hostname and base path#19

Merged
nschimme merged 2 commits into
MUME:masterfrom
nschimme:fix-sitemap-hostname-5332980858147929714
May 12, 2026
Merged

fix: correct sitemap.xml hostname and base path#19
nschimme merged 2 commits into
MUME:masterfrom
nschimme:fix-sitemap-hostname-5332980858147929714

Conversation

@nschimme
Copy link
Copy Markdown
Contributor

@nschimme nschimme commented May 12, 2026

Updated scripts/ci-env.sh to correctly identify the mume.github.io repository and set the VITE_HOSTNAME to https://docs.mume.org. Also explicitly set VITE_BASE to / for the official production environment and improved CNAME reading by stripping whitespace.

Updated .github/workflows/deploy.yml to prioritize VITE_BASE from the environment script and ensure no double-slashes are introduced when the base path is root.

Summary by Sourcery

Align production hostname and base path configuration for the mume.github.io deployment.

Enhancements:

  • Normalize CNAME-derived hostnames and correctly detect the official mume.github.io repository when setting VITE_HOSTNAME.
  • Explicitly set VITE_BASE to root for the official production environment and avoid double slashes in the deploy workflow when the base path is root.

Updated scripts/ci-env.sh to correctly identify the mume.github.io repository
and set the VITE_HOSTNAME to https://docs.mume.org. Also explicitly set
VITE_BASE to / for the official production environment and improved CNAME
reading by stripping whitespace.

Updated .github/workflows/deploy.yml to prioritize VITE_BASE from the
environment script and ensure no double-slashes are introduced when the
base path is root.
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 12, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjust CI environment script and deploy workflow to correctly derive VITE_HOSTNAME and VITE_BASE for the official mume.github.io production deployment and avoid malformed hostnames or double-slash base paths.

Flow diagram for CI env and deploy VITE_HOSTNAME/VITE_BASE logic

flowchart TD
  subgraph CI_env_sh
    A[Start CI env] --> B[Set OWNER from GITHUB_REPOSITORY_OWNER or mume]
    B --> C[Set REPO from GITHUB_REPOSITORY or OWNER/mume.github.io]

    C --> D{CNAME exists and OWNER = mume}
    D -->|yes| E[Read CNAME and strip whitespace to CNAME_VAL]
    E --> F[Set VITE_HOSTNAME=https://CNAME_VAL]

    D -->|no| G{PREVIEW_HOST is set}
    G -->|yes| H[Set VITE_HOSTNAME=https://PREVIEW_HOST + PREVIEW_PREFIX]

    G -->|no| I{OWNER = mume and REPO = mume.github.io}
    I -->|yes| J[Set VITE_HOSTNAME=https://docs.mume.org]
    I -->|yes| K[Set VITE_BASE=/]

    I -->|no| L{REPO = OWNER.github.io}
    L -->|yes| M[Set VITE_HOSTNAME=https://OWNER.github.io]
    L -->|no| N[Set VITE_HOSTNAME=https://OWNER.github.io/REPO]
  end

  subgraph Deploy_workflow
    O[Compute pages base_path] --> P{VITE_BASE in env}
    P -->|yes| Q[Use env.VITE_BASE]
    P -->|no| R[Set VITE_BASE=base_path/]
    Q --> S[npm run build]
    R --> S
  end

  F --> O
  H --> O
  J --> O
  M --> O
  N --> O
  K --> O
Loading

File-Level Changes

Change Details Files
Refine CI environment script logic for detecting the official mume.github.io repo and setting VITE_HOSTNAME and VITE_BASE.
  • Introduce OWNER and REPO variables with defaults and derive the repository name from GITHUB_REPOSITORY or a mume.github.io fallback.
  • Change CNAME-based hostname detection to use OWNER instead of GITHUB_REPOSITORY_OWNER and strip whitespace from the CNAME content before building VITE_HOSTNAME.
  • Update the fallback hostname mapping so that the official production site is recognized as mume.github.io and mapped to https://docs.mume.org instead of docs.
  • Preserve existing preview and fork hostname logic while adapting it to the new OWNER/REPO detection.
  • Explicitly set VITE_BASE=/ and export it to GITHUB_ENV when building the official mume.github.io production site.
scripts/ci-env.sh
Update deploy workflow to prefer VITE_BASE from the CI env script and avoid double slashes when base path is root.
  • Change the VITE_BASE environment assignment for the build step to first use env.VITE_BASE when present.
  • Fallback to formatting steps.pages.outputs.base_path with a single trailing slash to avoid double slashes when base_path is root.
.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

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 found 1 issue, and left some high level feedback:

  • In ci-env.sh, you can avoid the subshell and unnecessary cat by using input redirection with tr, e.g. export VITE_HOSTNAME="https://$(tr -d '[:space:]' < CNAME)", which is a bit more idiomatic and efficient in sh scripts.
  • Since OWNER and REPO are now computed at the top of ci-env.sh, you could simplify the later conditional branches by reusing them consistently and removing the redundant defaulting logic that was previously inside the fallback block.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `ci-env.sh`, you can avoid the subshell and unnecessary `cat` by using input redirection with `tr`, e.g. `export VITE_HOSTNAME="https://$(tr -d '[:space:]' < CNAME)"`, which is a bit more idiomatic and efficient in sh scripts.
- Since `OWNER` and `REPO` are now computed at the top of `ci-env.sh`, you could simplify the later conditional branches by reusing them consistently and removing the redundant defaulting logic that was previously inside the fallback block.

## Individual Comments

### Comment 1
<location path="scripts/ci-env.sh" line_range="10-12" />
<code_context>
 # Set VITE_HOSTNAME from CNAME file if it exists
-if [ -f CNAME ] && [ "$GITHUB_REPOSITORY_OWNER" = "mume" ]; then
-  export VITE_HOSTNAME="https://$(cat CNAME)"
+if [ -f CNAME ] && [ "$OWNER" = "mume" ]; then
+  export VITE_HOSTNAME="https://$(cat CNAME | tr -d '[:space:]')"
 else
   # Fallback for PR previews if host/prefix are provided via env
</code_context>
<issue_to_address>
**suggestion:** Avoid subshell `cat` usage and tighten quoting when reading CNAME.

You can avoid the subshell and improve readability by assigning the cleaned value first:

```sh
if [ -f CNAME ] && [ "$OWNER" = "mume" ]; then
  cname=$(tr -d '[:space:]' < CNAME)
  export VITE_HOSTNAME="https://$cname"
fi
```

```suggestion
# Set VITE_HOSTNAME from CNAME file if it exists
if [ -f CNAME ] && [ "$OWNER" = "mume" ]; then
  cname=$(tr -d '[:space:]' < CNAME)
  export VITE_HOSTNAME="https://$cname"
```
</issue_to_address>

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.

Comment thread scripts/ci-env.sh Outdated
Updated scripts/ci-env.sh to correctly identify the mume.github.io repository
and set the VITE_HOSTNAME to https://docs.mume.org. Used idiomatic shell
patterns for reading CNAME and ensured consistent variable usage.

Updated .github/workflows/deploy.yml to prioritize VITE_BASE from the
environment script and ensure no double-slashes are introduced when the
base path is root.
@nschimme
Copy link
Copy Markdown
Contributor Author

@sourcery-ai review

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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/deploy.yml" line_range="56" />
<code_context>
           if [ -f CNAME ] && [ "${{ github.repository_owner }}" = "mume" ]; then cp CNAME dist/CNAME; fi
         env:
-          VITE_BASE: ${{ steps.pages.outputs.base_path }}/
+          VITE_BASE: ${{ env.VITE_BASE || format('{0}/', steps.pages.outputs.base_path) }}

       - name: Collect PRs to deploy
</code_context>
<issue_to_address>
**issue (bug_risk):** Using `env.VITE_BASE` here will not pick up values written via `GITHUB_ENV` in earlier steps.

`env.VITE_BASE` is evaluated at workflow compile time, so it can only see values defined statically in the YAML, not those written later via `$GITHUB_ENV` (e.g. by `ci-env.sh`). This means the expression will never use the runtime override and will always prefer the YAML-defined value.

To use the dynamic value, either define `VITE_BASE` at job-level in YAML for the production case, or rely solely on the shell environment in the build step (for example, `VITE_BASE=${VITE_BASE:-"${{ steps.pages.outputs.base_path }}/"} npm run build`). Otherwise, the intended production override `VITE_BASE="/"` may be ignored.
</issue_to_address>

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.

if [ -f CNAME ] && [ "${{ github.repository_owner }}" = "mume" ]; then cp CNAME dist/CNAME; fi
env:
VITE_BASE: ${{ steps.pages.outputs.base_path }}/
VITE_BASE: ${{ env.VITE_BASE || format('{0}/', steps.pages.outputs.base_path) }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Using env.VITE_BASE here will not pick up values written via GITHUB_ENV in earlier steps.

env.VITE_BASE is evaluated at workflow compile time, so it can only see values defined statically in the YAML, not those written later via $GITHUB_ENV (e.g. by ci-env.sh). This means the expression will never use the runtime override and will always prefer the YAML-defined value.

To use the dynamic value, either define VITE_BASE at job-level in YAML for the production case, or rely solely on the shell environment in the build step (for example, VITE_BASE=${VITE_BASE:-"${{ steps.pages.outputs.base_path }}/"} npm run build). Otherwise, the intended production override VITE_BASE="/" may be ignored.

@nschimme nschimme merged commit 381da45 into MUME:master May 12, 2026
3 checks passed
@nschimme nschimme deleted the fix-sitemap-hostname-5332980858147929714 branch May 12, 2026 14:28
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