Repository navigation
fix(test): 避免 PATH 并发改写导致 Git 测试失败 #347
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: Commitlint | |
| on: | |
| push: | |
| branches: | |
| - "**" | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| - reopened | |
| permissions: | |
| contents: read | |
| # 同一 ref 只保留一组在途运行;PR 上新 push 取消旧运行 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| commitlint: | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| fetch-depth: 0 | |
| - name: 安装 pnpm | |
| uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10 | |
| - name: 安装 Node.js | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | |
| with: | |
| node-version: "24" | |
| cache: pnpm | |
| - name: 安装前端依赖 | |
| run: pnpm install --frozen-lockfile | |
| - name: 检查 Push 提交信息 | |
| if: github.event_name == 'push' | |
| run: | | |
| set -euo pipefail | |
| from="${{ github.event.before }}" | |
| to="${{ github.event.after }}" | |
| if [ "$from" = "0000000000000000000000000000000000000000" ]; then | |
| git fetch origin "${{ github.event.repository.default_branch }}" | |
| from="$(git merge-base "origin/${{ github.event.repository.default_branch }}" "$to")" | |
| fi | |
| pnpm exec commitlint --from "$from" --to "$to" --verbose | |
| - name: 检查 Pull Request 提交信息 | |
| if: github.event_name == 'pull_request' | |
| run: pnpm exec commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose |