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
17 changes: 3 additions & 14 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,11 @@ jobs:

const owner = context.repo.owner;
const repo = context.repo.repo;
let baseUrlPath = process.env.BASE_URL_PATH;
const baseUrlPath = process.env.BASE_URL_PATH;

let base = `https://${owner}.github.io`;

const cnamePath = 'CNAME';
if (fs.existsSync(cnamePath) && owner === 'mume') {
const domain = fs.readFileSync(cnamePath, 'utf8').trim();
if (domain) {
base = `https://${domain}`;
}
} else {
const repo = context.repo.repo;
if (repo !== `${owner}.github.io`) {
base = `${base}/${repo}`;
}
}
const normalizedPath = baseUrlPath.startsWith('/') ? baseUrlPath : `/${baseUrlPath}`;
base = `${base}${normalizedPath}`.replace(/\/$/, '');
Comment on lines +190 to +194

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): BASE_URL_PATH being undefined will throw at startsWith, consider a safe default or guard.

Since process.env.BASE_URL_PATH can be undefined, baseUrlPath.startsWith('/') will throw before the URL is built. Please add a safe default or guard, e.g. const baseUrlPath = process.env.BASE_URL_PATH || '';, and adjust the normalization so deployments without this env var still work.


const url = `${base}/pr-${pr.number}/`;
console.log(`Deployment URL for PR #${pr.number}: ${url}`);
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@ jobs:
- name: Determine Base URL Prefix
id: base_url
run: |
if [ -f CNAME ] && [ "${{ github.repository_owner }}" = "mume" ]; then
if [ "${{ github.event.repository.name }}" = "${{ github.repository_owner }}.github.io" ]; then
echo "prefix=/" >> $GITHUB_OUTPUT
echo "host=$(cat CNAME)" >> $GITHUB_OUTPUT
elif [ "${{ github.event.repository.name }}" = "${{ github.repository_owner }}.github.io" ]; then
echo "prefix=/" >> $GITHUB_OUTPUT
echo "host=${{ github.repository_owner }}.github.io" >> $GITHUB_OUTPUT
else
echo "prefix=/${{ github.event.repository.name }}/" >> $GITHUB_OUTPUT
echo "host=${{ github.repository_owner }}.github.io" >> $GITHUB_OUTPUT
fi
echo "host=${{ github.repository_owner }}.github.io" >> $GITHUB_OUTPUT

- name: Setup environment
run: ./scripts/ci-env.sh
Expand Down