Skip to content

Commit 7d7d71a

Browse files
committed
Also comment on PRs if they include Fix in the title but not [BUGFIX]
1 parent b057781 commit 7d7d71a

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66

77
permissions:
88
contents: read
9+
issues: write
910
pull-requests: read
1011

1112
jobs:
@@ -56,3 +57,44 @@ jobs:
5657
"Use an allowed bracket tag or no prefix."
5758
);
5859
}
60+
61+
comment-if-fix:
62+
name: Comment on PR if title includes "Fix" without a bracket tag
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Validate title
66+
uses: actions/github-script@v8
67+
with:
68+
script: |
69+
const title = context.payload.pull_request.title || "";
70+
const prNumber = context.payload.pull_request.number;
71+
const owner = context.repo.owner;
72+
const repo = context.repo.repo;
73+
74+
const marker = "<!-- pr-title-lint-fix-suggestion -->";
75+
const bracketMatch = title.match(/^\[[^\]]+\]/);
76+
if (!bracketMatch && /\bFix\b/i.test(title)) {
77+
const { data: comments } = await github.rest.issues.listComments({
78+
owner,
79+
repo,
80+
issue_number: prNumber
81+
});
82+
83+
const alreadyCommented = comments.some(
84+
(comment) =>
85+
comment.user?.type === "Bot" &&
86+
typeof comment.body === "string" &&
87+
comment.body.includes(marker)
88+
);
89+
90+
if (!alreadyCommented) {
91+
await github.rest.issues.createComment({
92+
owner,
93+
repo,
94+
issue_number: prNumber,
95+
body:
96+
`${marker}\n` +
97+
"This PR title includes \"Fix\". Should it include `[BUGFIX]` at the start? See https://github.com/emberjs/ember.js/blob/main/CONTRIBUTING.md#commit-tagging"
98+
});
99+
}
100+
}

0 commit comments

Comments
 (0)