Add commitlint workflow for better commit messages #34
Workflow file for this run
This file contains 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: | |
pull_request: # 只在 PR 事件时触发 | |
workflow_dispatch: # 允许手动触发 | |
jobs: | |
commitlint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # 获取完整的历史记录 | |
- name: Setup Node.js Environment | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Install Commitlint | |
run: npm install -g @commitlint/cli @commitlint/config-conventional | |
- name: Configure Commitlint | |
run: | | |
echo "module.exports = {extends: ['@commitlint/config-conventional']}" > commitlint.config.js | |
- name: Check Commits | |
run: | | |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then | |
commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose | |
fi |