Skip to content

Commit 7aacd84

Browse files
committed
fix(ci): enhance the PR title workflow
1 parent 8a9f113 commit 7aacd84

File tree

2 files changed

+60
-39
lines changed

2 files changed

+60
-39
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: Validate PR Title
3+
4+
on:
5+
pull_request_target:
6+
types:
7+
- opened
8+
- edited
9+
- synchronize
10+
11+
jobs:
12+
main:
13+
name: validate PR title
14+
runs-on: ubuntu-latest
15+
permissions:
16+
pull-requests: write
17+
statuses: write
18+
contents: read
19+
steps:
20+
- uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3
21+
id: lint_pr_title
22+
env:
23+
GITHUB_TOKEN: ${{ github.token }}
24+
with:
25+
types: |
26+
fix
27+
feat
28+
docs
29+
ci
30+
chore
31+
requireScope: false
32+
wip: true
33+
34+
- uses: marocchino/sticky-pull-request-comment@v2.9.0
35+
# When the previous steps fails, the workflow would stop. By adding this
36+
# condition you can continue the execution with the populated error message.
37+
if: always() && (steps.lint_pr_title.outputs.error_message != null)
38+
with:
39+
header: pr-title-lint-error
40+
GITHUB_TOKEN: ${{ github.token }}
41+
message: |
42+
Hey there and thank you for opening this pull request! 👋🏼
43+
44+
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.
45+
46+
If your PR is still a work in progress, please prefix the title with "[WIP]".
47+
48+
Details:
49+
50+
```
51+
${{ steps.lint_pr_title.outputs.error_message }}
52+
```
53+
54+
# Delete a previous comment when the issue has been resolved
55+
- if: ${{ steps.lint_pr_title.outputs.error_message == null }}
56+
uses: marocchino/sticky-pull-request-comment@v2.9.0
57+
with:
58+
header: pr-title-lint-error
59+
GITHUB_TOKEN: ${{ github.token }}
60+
delete: true

.github/workflows/validate-pr-title.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)