Skip to content

Commit 621e384

Browse files
committed
fix
1 parent 86c4ac4 commit 621e384

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

Diff for: .github/workflows/pr.yml

+21-6
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,32 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Check PR Title Prefix
12+
id: title-check
1213
uses: actions/github-script@v7
1314
with:
1415
script: |
15-
const titlePrefixes = ['feat', 'fix', 'break', 'chore'];
16+
const titlePrefixes = ["feat", "fix", "break", "chore"];
1617
const title = context.payload.pull_request.title.toLowerCase();
17-
const titleHasValidPrefix = titlePrefixes.some(prefix => title.startsWith(`${prefix}:`));
18-
if (!titleHasValidPrefix) { process.exit(-1); }
18+
const titleHasValidPrefix = titlePrefixes.some((prefix) => title.startsWith(`${prefix}:`));
19+
const message = titleHasValidPrefix
20+
? "🚨 PR title does not meet the requirements. It must start with one of the following prefixes: 'feat:', 'fix:', 'chore:', 'break:'."
21+
: "✅ PR title meet the requirements";
22+
return {
23+
message,
24+
titleHasValidPrefix,
25+
};
1926
20-
- if: failure()
21-
uses: thollander/actions-comment-pull-request@v2
27+
- uses: thollander/actions-comment-pull-request@v2
2228
with:
2329
message: |
24-
"🚨 PR title does not meet the requirements. It must start with one of the following prefixes: 'feat:', 'fix:', 'chore:', 'break:'."
30+
"${{ steps.title-check.outputs.result.message }}"
2531
comment_tag: PR title check result
32+
33+
- uses: actions/github-script@v7
34+
env:
35+
SUCCESS: ${{ steps.title-check.outputs.result.titleHasValidPrefix }}
36+
with:
37+
script: |
38+
const { SUCCESS } = process.env;
39+
console.log(SUCCESS);
40+
process.exit(-1);

0 commit comments

Comments
 (0)