Skip to content

Commit 5dae99b

Browse files
authored
ci: add friendly pr title message on error (#351)
Signed-off-by: Michael Beemer <[email protected]>
1 parent 5e01c24 commit 5dae99b

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

.github/workflows/pr-lint.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,36 @@ permissions:
1313
jobs:
1414
main:
1515
permissions:
16-
pull-requests: read # for amannn/action-semantic-pull-request to analyze PRs
16+
# for amannn/action-semantic-pull-request to analyze PR titles
17+
# for marocchino/sticky-pull-request-comment to add comments to the PR
18+
pull-requests: write
1719
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR
1820
name: Validate PR title
1921
runs-on: ubuntu-latest
2022
steps:
2123
- uses: amannn/action-semantic-pull-request@v5
2224
env:
2325
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- uses: marocchino/sticky-pull-request-comment@v2
28+
# When the previous steps fails, the workflow would stop. By adding this
29+
# condition you can continue the execution with the populated error message.
30+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
31+
with:
32+
header: pr-title-lint-error
33+
message: |
34+
Hey there and thank you for opening this pull request! 👋🏼
35+
36+
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.
37+
Details:
38+
39+
```
40+
${{ steps.lint_pr_title.outputs.error_message }}
41+
```
42+
43+
# Delete a previous comment when the issue has been resolved
44+
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
45+
uses: marocchino/sticky-pull-request-comment@v2
46+
with:
47+
header: pr-title-lint-error
48+
delete: true

0 commit comments

Comments
 (0)