Reputation: 3850
I want to create an automatic GitHub comment that is based on the title of the pull request. For my team, we want our pull request titles to be formatted in a certain way. If the pull request titles are not properly formatted, I would like to have a comment that is automatically added to the pull request asking the requester to change the title. How can I do this in GitHub?
Upvotes: 1
Views: 4973
Reputation: 545
name: PR Title Validation
on:
pull_request:
branches:
- integration
jobs:
comment:
runs-on: ubuntu-latest
if: "!startsWith(github.event.pull_request.title, 'PR - ')"
steps:
- uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Please change PR Title!!'
})
Upvotes: 3