Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrCai0907 committed Apr 3, 2024
1 parent 86c4ac4 commit 621e384
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,32 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check PR Title Prefix
id: title-check
uses: actions/github-script@v7
with:
script: |
const titlePrefixes = ['feat', 'fix', 'break', 'chore'];
const titlePrefixes = ["feat", "fix", "break", "chore"];
const title = context.payload.pull_request.title.toLowerCase();
const titleHasValidPrefix = titlePrefixes.some(prefix => title.startsWith(`${prefix}:`));
if (!titleHasValidPrefix) { process.exit(-1); }
const titleHasValidPrefix = titlePrefixes.some((prefix) => title.startsWith(`${prefix}:`));
const message = titleHasValidPrefix
? "🚨 PR title does not meet the requirements. It must start with one of the following prefixes: 'feat:', 'fix:', 'chore:', 'break:'."
: "✅ PR title meet the requirements";
return {
message,
titleHasValidPrefix,
};
- if: failure()
uses: thollander/actions-comment-pull-request@v2
- uses: thollander/actions-comment-pull-request@v2
with:
message: |
"🚨 PR title does not meet the requirements. It must start with one of the following prefixes: 'feat:', 'fix:', 'chore:', 'break:'."
"${{ steps.title-check.outputs.result.message }}"
comment_tag: PR title check result

- uses: actions/github-script@v7
env:
SUCCESS: ${{ steps.title-check.outputs.result.titleHasValidPrefix }}
with:
script: |
const { SUCCESS } = process.env;
console.log(SUCCESS);
process.exit(-1);

0 comments on commit 621e384

Please sign in to comment.