fix: resolve ESLint errors in vite.config.ts #21
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
| # Ultra-Optimized GitHub Pages Deployment | |
| # 业界最佳实践:SWC编译、双层缓存、并行构建、Lighthouse CI、安全加固 | |
| name: 🚀 Deploy Pages | |
| on: | |
| push: | |
| branches: [master, main] | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| - '.github/workflows/release.yml' | |
| pull_request: | |
| branches: [master, main] | |
| paths-ignore: | |
| - '**.md' | |
| - 'docs/**' | |
| workflow_dispatch: | |
| inputs: | |
| deploy_target: | |
| description: 'Deploy target' | |
| required: true | |
| default: 'production' | |
| type: choice | |
| options: [production, staging] | |
| # 最小权限原则 | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| pull-requests: write | |
| # 并发控制 | |
| concurrency: | |
| group: pages-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| NODE_VERSION: '22.14.0' | |
| DEPLOY_TARGET: ${{ github.event.inputs.deploy_target || 'production' }} | |
| jobs: | |
| # ========== 变更检测 ========== | |
| changes: | |
| name: 🔍 Detect Changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| frontend: ${{ steps.filter.outputs.frontend }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| frontend: | |
| - 'src/**' | |
| - 'public/**' | |
| - 'index.html' | |
| - 'package*.json' | |
| - 'vite.config.ts' | |
| - 'tsconfig*.json' | |
| - 'tailwind.config.*' | |
| # ========== 构建优化 ========== | |
| build: | |
| name: 🏗️ Build & Optimize | |
| runs-on: ubuntu-latest | |
| needs: changes | |
| if: ${{ needs.changes.outputs.frontend == 'true' || github.event_name == 'workflow_dispatch' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Enable Corepack | |
| run: corepack enable | |
| # 双层缓存策略 | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| id: cache-npm | |
| with: | |
| path: | | |
| ~/.npm | |
| node_modules/.cache | |
| .turbo | |
| key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} | |
| ${{ runner.os }}-npm- | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci --prefer-offline --no-audit --no-fund | |
| # 并行质量检查 | |
| - name: Type check | |
| run: npm run typecheck | |
| - name: Lint | |
| run: npm run lint | |
| - name: Test | |
| run: npm run test:run | |
| env: | |
| CI: true | |
| # 生产构建(使用 SWC) | |
| - name: Build | |
| run: npm run build:pages | |
| env: | |
| NODE_ENV: production | |
| VITE_COMMIT_SHA: ${{ github.sha }} | |
| VITE_REF_NAME: ${{ github.ref_name }} | |
| # 安全扫描 | |
| - name: Security audit | |
| run: | | |
| npm audit --audit-level=moderate || true | |
| if grep -r "sk-" dist/ 2>/dev/null; then | |
| echo "❌ Secret found in build!" | |
| exit 1 | |
| fi | |
| # 上传到 Pages | |
| - name: Upload to GitHub Pages | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./dist | |
| retention-days: 1 | |
| # ========== 部署 ========== | |
| deploy: | |
| name: 🌍 Deploy | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: success() | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| # ========== 健康检查 ========== | |
| healthcheck: | |
| name: ✓ Health Check | |
| runs-on: ubuntu-latest | |
| needs: deploy | |
| if: always() | |
| steps: | |
| - name: Wait for deployment | |
| run: sleep 15 | |
| - name: Check site health | |
| run: | | |
| URL="https://lessup.github.io/meta-human/" | |
| for i in {1..5}; do | |
| STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$URL") | |
| if [ "$STATUS" = "200" ]; then | |
| echo "✅ Site is healthy (HTTP $STATUS)" | |
| exit 0 | |
| fi | |
| sleep 5 | |
| done | |
| echo "❌ Health check failed" | |
| exit 1 |