@@ -150,20 +150,14 @@ jobs:
150150 body: `${icon} **${message}**\n\n**Built with:** Vite\n**Status:** ${status.toUpperCase()}`
151151 });
152152
153- # Job 4b: Deploy to GitHub Pages
154- deploy :
155- name : Deploy to GitHub Pages
153+ # Job 4b: Deploy to GitHub Pages (Develop Branch)
154+ deploy-develop :
155+ name : Deploy to /development/
156156 needs : build
157157 runs-on : ubuntu-latest
158- if : needs.build.outputs.build_status == 'success'
158+ if : needs.build.outputs.build_status == 'success' && github.ref_name == 'develop'
159159
160160 steps :
161- - name : Checkout gh-pages branch
162- uses : actions/checkout@v4
163- with :
164- ref : gh-pages
165- path : gh-pages-repo
166-
167161 - name : Download build artifact
168162 uses : actions/download-artifact@v4
169163 with :
@@ -175,79 +169,90 @@ jobs:
175169 cd artifact
176170 tar -xf artifact.tar
177171 mkdir -p ../dist
178- mv -f * ../dist/ 2>/dev/null || true
172+ mv * ../dist/ 2>/dev/null || true
179173 cd ..
180174 rm -rf artifact
181175
182- - name : Determine deployment path and update files
183- 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
184188 run : |
185- if [ "${{ github.ref_name }}" == "develop" ]; then
186- echo "📍 Deploying develop branch to /development/ subdirectory"
187- 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')
188202
189- # Remove old development folder and copy new build
190- rm -rf gh-pages-repo/development
191- mkdir -p gh-pages-repo/development
192- 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
193209
194- 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"
195215 else
196- echo "📍 Deploying main branch to root directory"
197- echo "url=https://www.unityailab.com/" >> $GITHUB_OUTPUT
198-
199- # Preserve CNAME and development folder
200- if [ -f "gh-pages-repo/CNAME" ]; then
201- cp gh-pages-repo/CNAME /tmp/CNAME
202- echo "💾 Preserved CNAME file"
203- fi
204-
205- if [ -d "gh-pages-repo/development" ]; then
206- mv gh-pages-repo/development /tmp/development
207- echo "💾 Preserved /development/ folder"
208- fi
209-
210- # Clear root and copy new build
211- rm -rf gh-pages-repo/*
212- cp -r dist/* gh-pages-repo/
213-
214- # Restore preserved files
215- if [ -f "/tmp/CNAME" ]; then
216- mv /tmp/CNAME gh-pages-repo/CNAME
217- echo "♻️ Restored CNAME file"
218- fi
219-
220- if [ -d "/tmp/development" ]; then
221- mv /tmp/development gh-pages-repo/development
222- echo "♻️ Restored /development/ folder"
223- fi
224-
225- echo "✅ Updated root files while preserving /development/"
216+ echo "ℹ️ No /development/ folder to preserve"
226217 fi
227218
228- - 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
229226 run : |
230- cd gh-pages-repo
231- git config user.name 'github-actions[bot]'
232- git config user.email 'github-actions[bot]@users.noreply.github.com'
233- 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
234233
235- if git diff --staged --quiet; then
236- echo "No changes to deploy"
237- else
238- git commit -m "Deploy from ${{ github.ref_name }} branch - $(date +'%Y-%m-%d %H:%M:%S')"
239- git push origin gh-pages
240- 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"
241239 fi
242240
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+
243251 - name : Report deployment success
244252 run : |
245253 echo "🚀 DEPLOYMENT SUCCESSFUL"
246254 echo "================================"
247255 echo "Branch: ${{ github.ref_name }}"
248- echo "URL: ${{ steps.deploy-path.outputs.url }} "
256+ echo "URL: https://www.unityailab.com/ "
249257 echo "Built with: Vite (optimized)"
250258 echo "================================"
251- echo ""
252- echo "✨ Your site is now live with the latest updates!"
253- echo "📦 Bundled, minified, and optimized for production"
0 commit comments