Skip to content

Commit 3ac48fb

Browse files
NickCrewscpcloud
andauthored
ci(ux): improve conventional commits check (#11150)
Co-authored-by: Phillip Cloud <[email protected]>
1 parent fd7fb36 commit 3ac48fb

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

.github/workflows/pr-title.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ jobs:
3737
echo "lint_output<<EOF"
3838
echo "$lint_output"
3939
echo "EOF"
40-
} >> "$GITHUB_OUTPUT"
40+
} | tee -a "$GITHUB_OUTPUT"
41+
exit $failed
4142
env:
4243
COMMIT_MSG: |
4344
${{ github.event.pull_request.title }}
@@ -47,11 +48,10 @@ jobs:
4748
comment-if-necessary:
4849
permissions:
4950
pull-requests: write
50-
name: Check PR title conforms to semantic-release
51+
name: Add/update comment describing commitlint failure
5152
runs-on: ubuntu-latest
5253
needs:
5354
- verify-commitlint
54-
if: needs.verify-commitlint.outputs.failed == '1'
5555
steps:
5656
- name: find existing comment
5757
uses: peter-evans/find-comment@v3
@@ -60,11 +60,13 @@ jobs:
6060
issue-number: ${{ github.event.pull_request.number }}
6161
body-includes: "ACTION NEEDED"
6262

63-
- name: post a message if the pull request title and body fail `commitlint`
64-
if: steps.find-comment.outputs.comment-body == ''
63+
- name: if the PR title and body fail `commitlint`, post or update a comment
64+
if: needs.verify-commitlint.outputs.failed == '1'
6565
uses: peter-evans/create-or-update-comment@v4
6666
with:
6767
issue-number: ${{ github.event.pull_request.number }}
68+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
69+
edit-mode: replace
6870
body: |
6971
**ACTION NEEDED**
7072
@@ -83,5 +85,11 @@ jobs:
8385
${{ needs.verify-commitlint.outputs.lint_output }}
8486
```
8587
86-
- name: fail the check because commitlint failed
87-
run: exit 1
88+
- name: If commitlint now passes, and comment exists, update it
89+
if: needs.verify-commitlint.outputs.failed == '0' && steps.find-comment.outputs.comment-id != ''
90+
uses: peter-evans/create-or-update-comment@v4
91+
with:
92+
issue-number: ${{ github.event.pull_request.number }}
93+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
94+
edit-mode: replace
95+
body: The PR title and description conform to the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/).

0 commit comments

Comments
 (0)