2022-09-14 09:50:55 +08:00
name : 📮 Lint Commit Message Post
2022-05-13 11:45:10 +08:00
on :
workflow_run :
2022-09-14 09:50:55 +08:00
workflows : [ 'Lint Commit Message' ]
2022-05-13 11:45:10 +08:00
types : [ completed]
jobs :
result :
runs-on : ubuntu-latest
2022-09-22 09:04:40 +08:00
2022-05-13 11:45:10 +08:00
outputs :
succeeded : ${{ steps.assert.outputs.succeeded }}
2022-05-17 10:54:03 +08:00
pr : ${{ steps.pr.outputs.pr }}
2022-09-22 09:04:40 +08:00
2022-05-13 11:45:10 +08:00
steps :
- name : Download result
2022-05-14 13:13:01 +08:00
uses : dawidd6/action-download-artifact@v2
2022-05-13 11:45:10 +08:00
with :
2022-05-14 12:04:13 +08:00
workflow : ${{ github.event.workflow.id }}
run_id : ${{ github.event.workflow_run.id }}
2022-05-13 11:45:10 +08:00
name : commit-lint-result
2022-09-22 09:04:40 +08:00
2022-05-17 10:54:03 +08:00
- name : Derive PR number
uses : dawidd6/action-download-artifact@v2
with :
workflow : ${{ github.event.workflow.id }}
run_id : ${{ github.event.workflow_run.id }}
name : pr-number
2022-05-13 11:45:10 +08:00
- name : Assert result
id : assert
2022-10-27 15:17:05 +08:00
run : echo "succeeded=$(<lint-result.txt)" >> $GITHUB_OUTPUT
2022-05-17 10:54:03 +08:00
- name : Get PR number
id : pr
2022-10-27 15:17:05 +08:00
run : echo "pr=$(<pr.txt)" >> $GITHUB_OUTPUT
2022-05-13 11:45:10 +08:00
on-success :
runs-on : ubuntu-latest
needs : result
if : ${{ needs.result.outputs.succeeded == 'true' }}
name : Lint successfully
steps :
2022-05-17 11:33:42 +08:00
- uses : actions-awesome/pr-helper@1.1.1
2022-05-13 11:45:10 +08:00
with :
actions : 'maintain-comment, add-labels, remove-labels'
token : ${{ github.token }}
labels-to-add : 'CommitMessage::Qualified'
labels-to-remove : 'CommitMessage::Unqualified'
body-filter : '<!-- ELEMENT_PLUS_COMMIT_LINT -->'
2022-05-17 10:54:03 +08:00
pr-number : ${{ needs.result.outputs.pr }}
2022-05-13 11:45:10 +08:00
on-failed :
runs-on : ubuntu-latest
needs : result
name : Lint failed
if : ${{ needs.result.outputs.succeeded != 'true' }}
steps :
2022-05-14 13:13:01 +08:00
- uses : dawidd6/action-download-artifact@v2
2022-05-13 11:45:10 +08:00
with :
2022-05-14 12:04:13 +08:00
workflow : ${{ github.event.workflow.id }}
run_id : ${{ github.event.workflow_run.id }}
2022-05-13 11:45:10 +08:00
name : commit-lint-report
- name : Read lint result
id : read
uses : juliangruber/read-file-action@v1
with :
path : ./commit-lint.txt
2022-05-17 11:33:42 +08:00
- uses : actions-awesome/pr-helper@1.1.1
2022-05-13 11:45:10 +08:00
with :
actions : 'remove-labels, add-labels, maintain-comment'
labels-to-remove : 'CommitMessage::Qualified'
labels-to-add : 'CommitMessage::Unqualified'
token : ${{ github.token }}
2022-05-17 10:54:03 +08:00
pr-number : ${{ needs.result.outputs.pr }}
2022-05-13 11:45:10 +08:00
comment-body : |
Hello, @${{ github.event.pull_request.user.login }}, seems like your commit message contains some issues.
你好,@${{ github.event.pull_request.user.login }},你的提交消息不符合 Element Plus 的提交消息规范。
```
${{ steps.read.outputs.content }}
```
2022-09-11 16:45:16 +08:00
Please refer to [Commit Example](https://element-plus.org/en-US/guide/commit-examples.html) for fixing it.
2022-05-13 11:45:10 +08:00
2022-09-11 16:45:16 +08:00
请参考 [提交示例](https://element-plus.org/en-US/guide/commit-examples.html) 来修改你的提交消息。
2022-05-13 11:45:10 +08:00
Note that all your commits will be squashed into one for being linted, so you might need to revision your commits.
If you do not know how to do so, please refer to [Keeping git commit history clean](https://about.gitlab.com/blog/2018/06/07/keeping-git-commit-history-clean/) to update your commit message.
你的所有 commit(s) 会被合并为一个 commit 来被验证,所以你可能需要修改你之前的 commit(s) 消息。
如果你不知道如何来修改之前已经提交的记录,请参考[让你的 Git 提交历史保持干净](https://about.gitlab.com/blog/2018/06/07/keeping-git-commit-history-clean/)来修改。
If you find it hard to do it by yourself, run command below to use an intuitive tool for that.
如果你觉得自己写这个提交消息很难,请使用下面的命令来启动一个交互式工具来帮助你生成消息。
```shell
pnpm cz
```
Note that if you do not fix the commit message issue, your PR will be automatically closed within **3 days**.
请注意,如果你没有按照规范修改你的提交消息,你的 PR 将会在**三天**内被自动关闭。
<sub>Generated with :heart : by ElementPlusBot</sub>
<!-- ELEMENT_PLUS_COMMIT_LINT -->
body-filter : '<!-- ELEMENT_PLUS_COMMIT_LINT -->'
- run : exit 1