feat: add workflow_call #3
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: Organization Commit Message Lint | |
| on: | |
| workflow_call: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| types: [opened, synchronize, edited, reopened] | |
| jobs: | |
| commitlint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # 必须完整历史才能比较提交 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install commitlint | |
| run: | | |
| npm install --save-dev @commitlint/{config-conventional,cli} | |
| - name: Run commitlint | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| npx commitlint --from=${{ github.event.pull_request.base.sha }} --to=${{ github.sha }} | |
| else | |
| npx commitlint --from=HEAD~1 --to=HEAD | |
| fi |