mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
ci: fix lint-commit-message not working for PR from fork (#22806)
* ci: fix lint-commit-message not working for PR from fork * chore: upgrade * ci: update
This commit is contained in:
78
.github/workflows/lint-commit-message-post.yml
vendored
Normal file
78
.github/workflows/lint-commit-message-post.yml
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
name: 📮 Lint Commit Message Post
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ['Lint Commit Message']
|
||||
types: [completed]
|
||||
|
||||
jobs:
|
||||
result:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
outputs:
|
||||
succeeded: ${{ steps.assert.outputs.succeeded }}
|
||||
pr: ${{ steps.pr.outputs.pr }}
|
||||
author: ${{ steps.author.outputs.author }}
|
||||
|
||||
steps:
|
||||
- name: Download result
|
||||
uses: dawidd6/action-download-artifact@v9
|
||||
with:
|
||||
workflow: ${{ github.event.workflow.id }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: commit-lint-result
|
||||
|
||||
- name: Derive PR number
|
||||
uses: dawidd6/action-download-artifact@v9
|
||||
with:
|
||||
workflow: ${{ github.event.workflow.id }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: pr-number
|
||||
|
||||
- name: Download PR author
|
||||
uses: dawidd6/action-download-artifact@v9
|
||||
with:
|
||||
workflow: ${{ github.event.workflow.id }}
|
||||
run_id: ${{ github.event.workflow_run.id }}
|
||||
name: pr-author
|
||||
|
||||
- name: Assert result
|
||||
id: assert
|
||||
run: echo "succeeded=$(<lint-result.txt)" >> $GITHUB_OUTPUT
|
||||
- name: Get PR number
|
||||
id: pr
|
||||
run: echo "pr=$(<pr.txt)" >> $GITHUB_OUTPUT
|
||||
- name: Get PR author
|
||||
id: author
|
||||
run: echo "author=$(<author.txt)" >> $GITHUB_OUTPUT
|
||||
|
||||
on-success:
|
||||
runs-on: ubuntu-latest
|
||||
needs: result
|
||||
name: Lint
|
||||
permissions:
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Successfully
|
||||
if: ${{ needs.result.outputs.succeeded == 'true' }}
|
||||
uses: actions-awesome/pr-helper@1.1.1
|
||||
with:
|
||||
actions: 'maintain-comment, add-labels, remove-labels'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
labels-to-remove: 'CommitMessage::Unqualified'
|
||||
body-filter: '<!-- ELEMENT_PLUS_COMMIT_LINT -->'
|
||||
pr-number: ${{ needs.result.outputs.pr }}
|
||||
|
||||
- name: Failed
|
||||
if: ${{ needs.result.outputs.succeeded != 'true' }}
|
||||
uses: actions-awesome/pr-helper@1.1.1
|
||||
with:
|
||||
actions: 'remove-labels, add-labels, maintain-comment'
|
||||
labels-to-add: 'CommitMessage::Unqualified'
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
pr-number: ${{ needs.result.outputs.pr }}
|
||||
comment-body: |
|
||||
Hello, @${{ needs.result.outputs.author }}, your PR title does not meet the standards, please [refer to here](https://github.com/element-plus/element-plus/commits/dev/).
|
||||
你好,@${{ needs.result.outputs.author }},你的 PR 标题不符合规范,[请参考这里](https://github.com/element-plus/element-plus/commits/dev/)。
|
||||
<!-- ELEMENT_PLUS_COMMIT_LINT -->
|
||||
body-filter: '<!-- ELEMENT_PLUS_COMMIT_LINT -->'
|
||||
40
.github/workflows/lint-commit-message.yml
vendored
40
.github/workflows/lint-commit-message.yml
vendored
@@ -14,6 +14,7 @@ jobs:
|
||||
failed: ${{ steps.lint_commit.outputs.failed == 'true' }}
|
||||
env:
|
||||
PULL_REQUEST_NUMBER: ${{ github.event.number }}
|
||||
PULL_REQUEST_AUTHOR: ${{ github.event.pull_request.user.login }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -36,24 +37,29 @@ jobs:
|
||||
|
||||
- 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 }}
|
||||
run: echo 'true' > ./lint-result.txt
|
||||
|
||||
- name: Set failed result
|
||||
if: ${{ steps.lint_commit.outputs.failed == 'true' }}
|
||||
uses: actions-awesome/pr-helper@1.1.1
|
||||
run: echo 'false' > ./lint-result.txt
|
||||
|
||||
- name: Set PR number
|
||||
run: echo "$PULL_REQUEST_NUMBER" > ./pr.txt
|
||||
|
||||
- name: Set PR author
|
||||
run: echo "$PULL_REQUEST_AUTHOR" > ./author.txt
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
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 -->'
|
||||
name: commit-lint-result
|
||||
path: ./lint-result.txt
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: pr-number
|
||||
path: ./pr.txt
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
with:
|
||||
name: pr-author
|
||||
path: ./author.txt
|
||||
|
||||
Reference in New Issue
Block a user