Files
element-plus/.github/workflows/lint-commit-message.yml

72 lines
2.7 KiB
YAML

name: Lint Commit Message
on:
pull_request:
types: [opened, edited, reopened]
jobs:
lint:
runs-on: ubuntu-latest
# if pull request title is D2M, then skip this job
if: ${{ !contains(github.event.pull_request.title, 'D2M') }}
continue-on-error: true
outputs:
failed: ${{ steps.lint_commit.outputs.failed == 'true' }}
env:
PULL_REQUEST_NUMBER: ${{ github.event.number }}
steps:
- uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm i --frozen-lockfile
- name: Lint commit
id: lint_commit
run: echo "${{ github.event.pull_request.title }}" | pnpm run lint:commit || echo "failed=true" >> $GITHUB_OUTPUT
- name: Set success result
if: ${{ steps.lint_commit.outputs.failed != 'true' }}
uses: actions-awesome/pr-helper@1.1.1
with:
actions: 'maintain-comment, add-labels, remove-labels'
token: ${{ github.token }}
labels-to-remove: 'CommitMessage::Unqualified'
body-filter: '<!-- ELEMENT_PLUS_COMMIT_LINT -->'
pr-number: ${{ github.event.number }}
- name: Set failed result
if: ${{ steps.lint_commit.outputs.failed == 'true' }}
uses: actions-awesome/pr-helper@1.1.1
with:
actions: 'remove-labels, add-labels, maintain-comment'
labels-to-add: 'CommitMessage::Unqualified'
token: ${{ github.token }}
pr-number: ${{ github.event.number }}
comment-body: |
Hello, @${{ github.event.pull_request.user.login }}, your PR title does not meet the standards, please refer to [commit-history](https://github.com/element-plus/element-plus/commits/dev/) or [docs-examples](https://element-plus.org/en-US/guide/commit-examples.html) make changes.
你好,@${{ github.event.pull_request.user.login }},你的 PR 标题不符合规范,请参考 [提交历史](https://github.com/element-plus/element-plus/commits/dev/) 或者 [文档示例](https://element-plus.org/en-US/guide/commit-examples.html) 进行修改。
<!-- ELEMENT_PLUS_COMMIT_LINT -->
body-filter: '<!-- ELEMENT_PLUS_COMMIT_LINT -->'