Skip to content

Commit 76f0c82

Browse files
authored
Fix Project build with no name in workflow: build-and-deploy.yml
1 parent 73dc49c commit 76f0c82

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

.github/workflows/build-and-deploy.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
with:
3131
node-version: '18'
3232

33-
- name: Install json tool
33+
- name: Install json CLI (optional if needed later)
3434
run: npm install -g json
3535

3636
- name: Build all Vite React projects
@@ -39,23 +39,28 @@ jobs:
3939
rm -rf output
4040
mkdir -p output
4141
42-
echo "$PROJECT_LIST" | while IFS= read -r project; do
42+
while IFS= read -r project; do
43+
[ -z "$project" ] && continue # Skip empty lines
44+
45+
echo "========================"
4346
echo "📦 Building $project"
47+
echo "========================"
48+
4449
cd "$project"
4550
npm install
4651
47-
# Inject vite.config.js with correct base
52+
# Inject vite.config.js with correct base path
4853
base="/$repo_name/$project/"
4954
echo "import { defineConfig } from 'vite';" > vite.config.js
5055
echo "import react from '@vitejs/plugin-react';" >> vite.config.js
5156
echo "export default defineConfig({ base: '$base', plugins: [react()] });" >> vite.config.js
5257
53-
npm run build
58+
npx vite build
5459
cd ..
5560
5661
mkdir -p "output/$project"
5762
cp -r "$project/dist/." "output/$project/"
58-
done
63+
done <<< "$PROJECT_LIST"
5964
6065
- name: Deploy to `docs` branch
6166
run: |
@@ -79,8 +84,8 @@ jobs:
7984
echo ""
8085
8186
repo_name="${GITHUB_REPOSITORY#*/}"
82-
echo "$PROJECT_LIST" | while IFS= read -r project; do
87+
while IFS= read -r project; do
88+
[ -z "$project" ] && continue
8389
encoded_project=$(echo "$project" | sed 's/ /%20/g')
84-
url="https://${GITHUB_REPOSITORY_OWNER}.github.io/${repo_name}/${encoded_project}/"
85-
echo "🌐 $project → $url"
86-
done
90+
echo "🌐 $project → https://${GITHUB_REPOSITORY_OWNER}.github.io/${repo_name}/${encoded_project}/"
91+
done <<< "$PROJECT_LIST"

0 commit comments

Comments
 (0)