perf(lighthouse): 實施Lighthouse性能優化最佳實踐 #38
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: 🚀 自動發布 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| # 基於 Context7 最佳實踐的權限配置 | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| id-token: write # npm provenance 需要 | |
| jobs: | |
| # 測試和品質檢查作業 | |
| quality: | |
| name: 🔍 品質檢查 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 📥 檢出程式碼 | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: 🟢 設定 Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 'lts/*' | |
| cache: 'npm' | |
| - name: 📦 安裝依賴 | |
| run: npm ci | |
| - name: 🧪 執行測試 | |
| run: npm test | |
| - name: 🔍 程式碼品質檢查 | |
| run: npm run lint | |
| - name: 🔨 建置專案 | |
| run: npm run build | |
| # 發布作業 - 只有在品質檢查通過後執行 | |
| release: | |
| name: 🎯 發布新版本 | |
| runs-on: ubuntu-latest | |
| needs: quality | |
| steps: | |
| - name: 📥 檢出程式碼 | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: 🟢 設定 Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 'lts/*' | |
| cache: 'npm' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: 📦 安裝依賴 | |
| run: npm clean-install | |
| - name: 🔍 驗證依賴完整性 | |
| run: npm audit signatures | |
| - name: 🚀 發布新版本 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npx semantic-release | |
| # 注意:版本號檔案更新和 Git 提交由 semantic-release 自動處理 |