Update deploy-to-master.yml #9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Ultra-Fast Deploy to Master Branch | |
| on: | |
| push: | |
| branches: [ next ] | |
| workflow_dispatch: | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1️⃣ Checkout next branch | |
| - name: Checkout next branch | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # 2️⃣ Setup Node.js | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| # 3️⃣ Install dependencies including terser | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| npm install --save-dev terser | |
| # 4️⃣ Build + create .env + prepare deploy folder (all in one) | |
| - name: Build project and prepare deploy folder | |
| run: | | |
| # Create production .env | |
| echo "GEMINI_API_KEY=${{ secrets.GEMINI_API_KEY || '' }}" > .env.production | |
| echo "VITE_ENABLE_CHATBOT=${{ secrets.VITE_ENABLE_CHATBOT || 'false' }}" >> .env.production | |
| echo "VITE_ENABLE_DYNAMIC_CONTENT=${{ secrets.VITE_ENABLE_DYNAMIC_CONTENT || 'false' }}" >> .env.production | |
| echo "VITE_SHOW_DEV_ELEMENTS=false" >> .env.production | |
| echo "VITE_SHOW_VISITOR_CONTROLS=false" >> .env.production | |
| echo "VITE_SHOW_PROFILE_INSIGHTS=false" >> .env.production | |
| echo "VITE_SHOW_TRANSLATION_DEBUG=false" >> .env.production | |
| echo "VITE_SHOW_DEBUG_INFO=false" >> .env.production | |
| # Build project in production mode | |
| npm run build:prod | |
| # Ensure dist exists | |
| if [ ! -d dist ]; then | |
| echo "Error: dist/ folder not found. Build failed." | |
| exit 1 | |
| fi | |
| # Prepare deploy folder | |
| mkdir -p deploy | |
| cp -r dist/* deploy/ | |
| cp .env.production deploy/ | |
| cp .env.example deploy/ | |
| cp README.md deploy/ | |
| cp package.json deploy/ | |
| # 5️⃣ Deploy directly to master branch | |
| - name: Deploy to GitHub Pages (master branch) | |
| uses: peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./deploy | |
| publish_branch: master | |
| force_orphan: true # completely replaces master content |