5151
5252 - name : Build with Vite
5353 id : build_check
54+ env :
55+ VITE_BASE_PATH : ${{ github.ref_name == 'develop' && '/development/' || '/' }}
5456 run : |
5557 echo "🏗️ Building with Vite..."
58+ echo "📍 Base path: $VITE_BASE_PATH"
59+ echo "🌿 Branch: ${{ github.ref_name }}"
5660 npm run build
5761
5862 # Check if build succeeded
@@ -146,20 +150,14 @@ jobs:
146150 body: `${icon} **${message}**\n\n**Built with:** Vite\n**Status:** ${status.toUpperCase()}`
147151 });
148152
149- # Job 4b: Deploy to GitHub Pages
150- deploy :
151- name : Deploy to GitHub Pages
153+ # Job 4b: Deploy to GitHub Pages (Develop Branch)
154+ deploy-develop :
155+ name : Deploy to /development/
152156 needs : build
153157 runs-on : ubuntu-latest
154- if : needs.build.outputs.build_status == 'success'
158+ if : needs.build.outputs.build_status == 'success' && github.ref_name == 'develop'
155159
156160 steps :
157- - name : Checkout gh-pages branch
158- uses : actions/checkout@v4
159- with :
160- ref : gh-pages
161- path : gh-pages-repo
162-
163161 - name : Download build artifact
164162 uses : actions/download-artifact@v4
165163 with :
@@ -171,79 +169,90 @@ jobs:
171169 cd artifact
172170 tar -xf artifact.tar
173171 mkdir -p ../dist
174- mv -f * ../dist/ 2>/dev/null || true
172+ mv * ../dist/ 2>/dev/null || true
175173 cd ..
176174 rm -rf artifact
177175
178- - name : Determine deployment path and update files
179- id : deploy-path
176+ - name : Deploy to /development/ subdirectory
177+ uses : peaceiris/actions-gh-pages@v4
178+ with :
179+ github_token : ${{ secrets.GITHUB_TOKEN }}
180+ publish_dir : ./dist
181+ destination_dir : development
182+ keep_files : true
183+ user_name : ' github-actions[bot]'
184+ user_email : ' github-actions[bot]@users.noreply.github.com'
185+ commit_message : ' Deploy develop branch to /development/'
186+
187+ - name : Report deployment success
180188 run : |
181- if [ "${{ github.ref_name }}" == "develop" ]; then
182- echo "📍 Deploying develop branch to /development/ subdirectory"
183- echo "url=https://www.unityailab.com/development/" >> $GITHUB_OUTPUT
189+ echo "🚀 DEPLOYMENT SUCCESSFUL"
190+ echo "================================"
191+ echo "Branch: develop"
192+ echo "URL: https://www.unityailab.com/development/"
193+ echo "Built with: Vite (optimized)"
194+ echo "================================"
195+
196+ # Job 4c: Deploy to GitHub Pages (Main Branch)
197+ deploy-main :
198+ name : Deploy to Root
199+ needs : build
200+ runs-on : ubuntu-latest
201+ if : needs.build.outputs.build_status == 'success' && (github.ref_name == 'main' || github.ref_name == 'master')
184202
185- # Remove old development folder and copy new build
186- rm -rf gh-pages-repo/development
187- mkdir -p gh-pages-repo/development
188- cp -r dist/* gh-pages-repo/development/
203+ steps :
204+ - name : Checkout gh-pages branch
205+ uses : actions/checkout@v4
206+ with :
207+ ref : gh-pages
208+ path : gh-pages-backup
189209
190- echo "✅ Updated /development/ folder only"
210+ - name : Preserve /development/ folder
211+ run : |
212+ if [ -d "gh-pages-backup/development" ]; then
213+ cp -r gh-pages-backup/development /tmp/development-backup
214+ echo "💾 Preserved /development/ folder"
191215 else
192- echo "📍 Deploying main branch to root directory"
193- echo "url=https://www.unityailab.com/" >> $GITHUB_OUTPUT
194-
195- # Preserve CNAME and development folder
196- if [ -f "gh-pages-repo/CNAME" ]; then
197- cp gh-pages-repo/CNAME /tmp/CNAME
198- echo "💾 Preserved CNAME file"
199- fi
200-
201- if [ -d "gh-pages-repo/development" ]; then
202- mv gh-pages-repo/development /tmp/development
203- echo "💾 Preserved /development/ folder"
204- fi
205-
206- # Clear root and copy new build
207- rm -rf gh-pages-repo/*
208- cp -r dist/* gh-pages-repo/
209-
210- # Restore preserved files
211- if [ -f "/tmp/CNAME" ]; then
212- mv /tmp/CNAME gh-pages-repo/CNAME
213- echo "♻️ Restored CNAME file"
214- fi
215-
216- if [ -d "/tmp/development" ]; then
217- mv /tmp/development gh-pages-repo/development
218- echo "♻️ Restored /development/ folder"
219- fi
220-
221- echo "✅ Updated root files while preserving /development/"
216+ echo "ℹ️ No /development/ folder to preserve"
222217 fi
223218
224- - name : Commit and push to gh-pages
219+ - name : Download build artifact
220+ uses : actions/download-artifact@v4
221+ with :
222+ name : github-pages
223+ path : artifact
224+
225+ - name : Extract artifact
225226 run : |
226- cd gh-pages-repo
227- git config user.name 'github-actions[bot]'
228- git config user.email 'github-actions[bot]@users.noreply.github.com'
229- git add -A
227+ cd artifact
228+ tar -xf artifact.tar
229+ mkdir -p ../dist
230+ mv * ../dist/ 2>/dev/null || true
231+ cd ..
232+ rm -rf artifact
230233
231- if git diff --staged --quiet; then
232- echo "No changes to deploy"
233- else
234- git commit -m "Deploy from ${{ github.ref_name }} branch - $(date +'%Y-%m-%d %H:%M:%S')"
235- git push origin gh-pages
236- echo "✅ Deployed successfully"
234+ - name : Restore /development/ folder to build
235+ run : |
236+ if [ -d "/tmp/development-backup" ]; then
237+ cp -r /tmp/development-backup dist/development
238+ echo "♻️ Restored /development/ folder to deployment"
237239 fi
238240
241+ - name : Deploy to root directory
242+ uses : peaceiris/actions-gh-pages@v4
243+ with :
244+ github_token : ${{ secrets.GITHUB_TOKEN }}
245+ publish_dir : ./dist
246+ keep_files : false
247+ user_name : ' github-actions[bot]'
248+ user_email : ' github-actions[bot]@users.noreply.github.com'
249+ commit_message : ' Deploy main branch to root'
250+
239251 - name : Report deployment success
240252 run : |
241253 echo "🚀 DEPLOYMENT SUCCESSFUL"
242254 echo "================================"
243255 echo "Branch: ${{ github.ref_name }}"
244- echo "URL: ${{ steps.deploy-path.outputs.url }} "
256+ echo "URL: https://www.unityailab.com/ "
245257 echo "Built with: Vite (optimized)"
246258 echo "================================"
247- echo ""
248- echo "✨ Your site is now live with the latest updates!"
249- echo "📦 Bundled, minified, and optimized for production"
0 commit comments