mirror of
https://github.com/zhigang1992/pr-title.git
synced 2026-01-12 08:14:30 +08:00
Add custom message support
This commit is contained in:
3
.github/pr-title.yml
vendored
3
.github/pr-title.yml
vendored
@@ -1 +1,2 @@
|
||||
regex: ^PR-TITLE.*$
|
||||
regex: ^PR-TITLE.*$
|
||||
message: Please correct your PR Title
|
||||
8
app.yml
8
app.yml
@@ -20,7 +20,7 @@ default_events:
|
||||
# - fork
|
||||
# - gollum
|
||||
# - issue_comment
|
||||
- issues
|
||||
# - issues
|
||||
# - label
|
||||
# - milestone
|
||||
# - member
|
||||
@@ -32,7 +32,7 @@ default_events:
|
||||
# - project_card
|
||||
# - project_column
|
||||
# - public
|
||||
# - pull_request
|
||||
- pull_request
|
||||
# - pull_request_review
|
||||
# - pull_request_review_comment
|
||||
# - push
|
||||
@@ -67,7 +67,7 @@ default_permissions:
|
||||
|
||||
# Issues and related comments, assignees, labels, and milestones.
|
||||
# https://developer.github.com/v3/apps/permissions/#permission-on-issues
|
||||
issues: write
|
||||
# issues: write
|
||||
|
||||
# Search repositories, list collaborators, and access repository metadata.
|
||||
# https://developer.github.com/v3/apps/permissions/#metadata-permissions
|
||||
@@ -79,7 +79,7 @@ default_permissions:
|
||||
|
||||
# Pull requests and related comments, assignees, labels, milestones, and merges.
|
||||
# https://developer.github.com/v3/apps/permissions/#permission-on-pull-requests
|
||||
# pull_requests: read
|
||||
pull_requests: write
|
||||
|
||||
# Manage the post-receive hooks for a repository.
|
||||
# https://developer.github.com/v3/apps/permissions/#permission-on-repository-hooks
|
||||
|
||||
17
src/index.ts
17
src/index.ts
@@ -3,14 +3,23 @@ import { Application } from 'probot'
|
||||
import getConfig from 'probot-config'
|
||||
|
||||
export = (app: Application) => {
|
||||
app.log('App Loaded')
|
||||
app.on(['pull_request.opened', 'pull_request.edited'], async (context) => {
|
||||
context.log('Event triggered')
|
||||
const config = await getConfig(context, 'pr-title.yml');
|
||||
if (config && typeof config.regex === 'string') {
|
||||
app.log(config.regex)
|
||||
app.log(context.payload.pull_request)
|
||||
context.log(config.regex)
|
||||
const title: string = context.payload.pull_request.title;
|
||||
if ((new RegExp(config.regex)).test(title)) {
|
||||
context.log('No action needed')
|
||||
return;
|
||||
}
|
||||
const comment = context.issue({
|
||||
body: config.message || "Please correct your PR title"
|
||||
})
|
||||
context.github.issues.createComment(comment)
|
||||
} else {
|
||||
app.log('config file not found')
|
||||
context.log('config file not found')
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user