Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
npm run build
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.


- name: Collect PRs to deploy
uses: actions/github-script@v9
Expand Down
18 changes: 13 additions & 5 deletions scripts/ci-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
export VITE_LAST_UPDATED=$(git log -1 --format=%cd --date=format:'%B %Y')
echo "VITE_LAST_UPDATED=$VITE_LAST_UPDATED" >> $GITHUB_ENV

OWNER="${GITHUB_REPOSITORY_OWNER:-mume}"
REPO=$(echo "${GITHUB_REPOSITORY:-${OWNER}/mume.github.io}" | cut -d'/' -f2)

# 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
CNAME_VAL=$(tr -d '[:space:]' < CNAME)
export VITE_HOSTNAME="https://$CNAME_VAL"
else
# Fallback for PR previews if host/prefix are provided via env
if [ -n "$PREVIEW_HOST" ]; then
export VITE_HOSTNAME="https://${PREVIEW_HOST}${PREVIEW_PREFIX}"
else
# Fallback for forks or main repo without CNAME
OWNER="${GITHUB_REPOSITORY_OWNER:-mume}"
REPO=$(echo "${GITHUB_REPOSITORY:-${OWNER}/docs}" | cut -d'/' -f2)
if [ "$OWNER" = "mume" ] && [ "$REPO" = "docs" ]; then
if [ "$OWNER" = "mume" ] && [ "$REPO" = "mume.github.io" ]; then
export VITE_HOSTNAME="https://docs.mume.org"
elif [ "$REPO" = "$OWNER.github.io" ]; then
export VITE_HOSTNAME="https://$OWNER.github.io"
Expand All @@ -25,3 +27,9 @@ else
fi
fi
echo "VITE_HOSTNAME=$VITE_HOSTNAME" >> $GITHUB_ENV

# Explicitly set VITE_BASE=/ for the official production environment
if [ "$OWNER" = "mume" ] && [ "$REPO" = "mume.github.io" ]; then
export VITE_BASE="/"
echo "VITE_BASE=$VITE_BASE" >> $GITHUB_ENV
fi