name: Verify Web on: push: branches: [main] # 只改文档/CI 自身不触发:省 GitHub Actions 免费分钟(额度按 job 分钟累计) paths-ignore: - '**/*.md' - 'docs/**' - '.github/**' pull_request: branches: [main] workflow_dispatch: # 同一分支连推多次时取消旧任务,只跑最后一次 concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true permissions: contents: read jobs: gate: name: gate (build · lint · unit · facts) runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@v4 with: # 完整历史(非浅克隆):事实守门第 7 组要读 package.json 的**父提交**来定位 # 「最近一次 bump 版本的提交」⇒ 浅克隆下 `HEAD^` 不存在会导致门禁误报失败。 # 仓库很小(打包后 ~3MB),取全历史成本可忽略。 fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: 22 cache: npm - run: npm ci - run: npm run verify:ci e2e: name: e2e (Playwright) # e2e 是最贵的 job:push 到 main 不再跑,只在 PR / 手动触发时跑 if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-node@v4 with: node-version: 22 cache: npm - run: npm ci - name: Cache Playwright browsers uses: actions/cache@v4 with: path: ~/.cache/ms-playwright key: playwright-${{ runner.os }}-${{ hashFiles('package-lock.json') }} - run: npx playwright install --with-deps chromium - run: npm run test:e2e