Skip to content

Commit cc05880

Browse files
committed
Add optional dependency handling and expected GitHub Pages URL output for deployment
1 parent 4f35899 commit cc05880

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

.github/workflows/static.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
run: |
3939
# Ensure required native deps for image optimization binaries (pngquant) are present
4040
sudo apt-get update && sudo apt-get install -y libpng-dev build-essential pkg-config || true
41+
# Avoid installing optional native binaries that sometimes fail in CI
42+
export npm_config_optional=false
4143
if [ -f package-lock.json ]; then npm ci; else npm install; fi
4244
4345
- name: Determine deploy subpath
@@ -73,6 +75,15 @@ jobs:
7375
export PUBLIC_URL="$DEPLOY_BASE"
7476
export VITE_BASE_PATH="$DEPLOY_BASE"
7577
echo "Building with DEPLOY_BASE=$DEPLOY_BASE"
78+
79+
# Print the expected GitHub Pages URL to make verification easier
80+
OWNER=${GITHUB_REPOSITORY%%/*}
81+
REPO=${GITHUB_REPOSITORY#*/}
82+
# strip possible .git (unlikely in GITHUB_REPOSITORY but safe)
83+
REPO=$(basename -s .git "$REPO")
84+
# Construct URL without trailing slash
85+
EXPECTED_URL="https://${OWNER}.github.io/${REPO}${DEPLOY_BASE%/}"
86+
echo "Expected Pages URL: $EXPECTED_URL"
7687
7788
npm run build
7889
# Ensure SPA routes work on GitHub Pages by providing a 404 fallback
@@ -110,6 +121,8 @@ jobs:
110121
run: |
111122
# Ensure required native deps for image optimization binaries (pngquant) are present
112123
sudo apt-get update && sudo apt-get install -y libpng-dev build-essential pkg-config || true
124+
# Avoid installing optional native binaries that sometimes fail in CI
125+
export npm_config_optional=false
113126
if [ -f package-lock.json ]; then npm ci; else npm install; fi
114127
115128
- name: Determine deploy subpath
@@ -145,6 +158,12 @@ jobs:
145158
export PUBLIC_URL="$DEPLOY_BASE"
146159
export VITE_BASE_PATH="$DEPLOY_BASE"
147160
echo "Building with DEPLOY_BASE=$DEPLOY_BASE"
161+
# Print the expected GitHub Pages URL to make verification easier
162+
OWNER=${GITHUB_REPOSITORY%%/*}
163+
REPO=${GITHUB_REPOSITORY#*/}
164+
REPO=$(basename -s .git "$REPO")
165+
EXPECTED_URL="https://${OWNER}.github.io/${REPO}${DEPLOY_BASE%/}"
166+
echo "Expected Pages URL: $EXPECTED_URL"
148167
149168
npm run build
150169
# Ensure SPA routes work on GitHub Pages by providing a 404 fallback

0 commit comments

Comments
 (0)