Skip to content

Commit 8f48b2a

Browse files
committed
Fix GitHub Pages deployment by setting proper BASE_PATH for custom domain and copying CNAME file
1 parent 46bd30c commit 8f48b2a

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,26 @@ jobs:
2121
- name: Install dependencies
2222
run: npm install --legacy-peer-deps
2323

24+
- name: Check for CNAME file
25+
id: check-cname
26+
run: |
27+
if [ -f "CNAME" ]; then
28+
echo "cname_exists=true" >> $GITHUB_OUTPUT
29+
else
30+
echo "cname_exists=false" >> $GITHUB_OUTPUT
31+
fi
32+
2433
- name: Build
2534
env:
26-
BASE_PATH: '/${{ github.event.repository.name }}'
35+
BASE_PATH: ${{ steps.check-cname.outputs.cname_exists == 'true' && '' || format('/{0}', github.event.repository.name) }}
2736
run: |
2837
npm run build
2938
39+
- name: Copy CNAME file to build directory if it exists
40+
if: steps.check-cname.outputs.cname_exists == 'true'
41+
run: |
42+
cp CNAME build/
43+
3044
- name: Upload Pages artifact
3145
uses: actions/upload-pages-artifact@v3
3246
with:
@@ -44,4 +58,4 @@ jobs:
4458
steps:
4559
- name: Deploy
4660
id: deployment
47-
uses: actions/deploy-pages@v4
61+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)