11name : Build and Deploy
22
3- # Run on push to main/master/develop branch
3+ # Run on push to main/master branch only
44on :
55 push :
66 branches :
77 - main
88 - master
9- - develop
109 workflow_dispatch : # Allow manual triggering
1110
1211# Grant necessary permissions
4645
4746 - name : Build with Vite
4847 id : build_check
49- env :
50- VITE_BASE_PATH : ${{ github.ref_name == 'develop' && '/development/' || '/' }}
5148 run : |
5249 echo "🏗️ Building with Vite..."
53- echo "📍 Base path: $VITE_BASE_PATH"
54- echo "🌿 Branch: ${{ github.ref_name }}"
5550 npm run build
5651
5752 # Check if build succeeded
@@ -145,31 +140,14 @@ jobs:
145140 body: `${icon} **${message}**\n\n**Built with:** Vite\n**Status:** ${status.toUpperCase()}`
146141 });
147142
148- # Job 4b: Deploy to GitHub Pages (Unified)
143+ # Job 4b: Deploy to GitHub Pages
149144 deploy :
150145 name : Deploy to GitHub Pages
151146 needs : build
152147 runs-on : ubuntu-latest
153148 if : needs.build.outputs.build_status == 'success'
154149
155150 steps :
156- - name : Checkout gh-pages branch (for main branch only)
157- if : github.ref_name == 'main' || github.ref_name == 'master'
158- uses : actions/checkout@v4
159- with :
160- ref : gh-pages
161- path : gh-pages-backup
162-
163- - name : Preserve /development/ folder (for main branch only)
164- if : github.ref_name == 'main' || github.ref_name == 'master'
165- run : |
166- if [ -d "gh-pages-backup/development" ]; then
167- cp -r gh-pages-backup/development /tmp/development-backup
168- echo "💾 Preserved /development/ folder"
169- else
170- echo "ℹ️ No /development/ folder to preserve"
171- fi
172-
173151 - name : Download build artifact
174152 uses : actions/download-artifact@v4
175153 with :
@@ -185,39 +163,21 @@ jobs:
185163 cd ..
186164 rm -rf artifact
187165
188- - name : Restore /development/ folder (for main branch only)
189- if : github.ref_name == 'main' || github.ref_name == 'master'
190- run : |
191- if [ -d "/tmp/development-backup" ]; then
192- cp -r /tmp/development-backup dist/development
193- echo "♻️ Restored /development/ folder to deployment"
194- fi
195-
196166 - name : Deploy to GitHub Pages
197167 uses : peaceiris/actions-gh-pages@v4
198168 with :
199169 github_token : ${{ secrets.GITHUB_TOKEN }}
200170 publish_dir : ./dist
201- destination_dir : ${{ github.ref_name == 'develop' && 'development' || '.' }}
202- keep_files : ${{ github.ref_name == 'develop' && 'true' || 'false' }}
171+ keep_files : false
203172 user_name : ' github-actions[bot]'
204173 user_email : ' github-actions[bot]@users.noreply.github.com'
205- commit_message : ' Deploy ${{ github.ref_name }} branch'
174+ commit_message : ' Deploy from main branch'
206175
207176 - name : Report deployment success
208177 run : |
209- if [ "${{ github.ref_name }}" == "develop" ]; then
210- DEPLOY_URL="https://www.unityailab.com/development/"
211- DEPLOY_PATH="/development/"
212- else
213- DEPLOY_URL="https://www.unityailab.com/"
214- DEPLOY_PATH="root"
215- fi
216-
217178 echo "🚀 DEPLOYMENT SUCCESSFUL"
218179 echo "================================"
219180 echo "Branch: ${{ github.ref_name }}"
220- echo "Deploy Path: $DEPLOY_PATH"
221- echo "URL: $DEPLOY_URL"
181+ echo "URL: https://www.unityailab.com/"
222182 echo "Built with: Vite (optimized)"
223183 echo "================================"
0 commit comments