mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-20 10:57:45 +08:00
31
.github/workflows/pr-checker.yml
vendored
Normal file
31
.github/workflows/pr-checker.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
name: PR Checker
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, ready_for_review, reopened, synchronize]
|
||||
|
||||
jobs:
|
||||
check_commit_name_in_pr:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check Commits
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const { data: commits } = await github.rest.pulls.listCommits({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.payload.pull_request.number
|
||||
});
|
||||
|
||||
const regex = /^((build|chore|ci|docs?|feat|fix|perf|refactor|rft|style|test)[\:\.\(\,]|[Rr]evert|[Rr]elease)/;
|
||||
const invalidCommits = commits.filter(commit => !regex.test(commit.commit.message));
|
||||
|
||||
console.log(`check ${commits.length} commit(s)`);
|
||||
|
||||
if (invalidCommits.length > 0) {
|
||||
const invalidCommitNames = invalidCommits.map(commit => commit.commit.message);
|
||||
core.setFailed(`Invalid commit names found: ${invalidCommitNames.join(", ")}`);
|
||||
}
|
||||
Reference in New Issue
Block a user