如何根据请求标题创建一个自动GitHub注释



我想创建一个基于pull请求标题的自动GitHub注释。对于我的团队来说,我们希望我们的拉取请求标题以某种方式格式化。如果拉取请求标题的格式不正确,我希望在拉取请求中自动添加一条注释,要求请求者更改标题。我如何在GitHub中做到这一点?

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!!'
})

更多表达式(如果需要(

最新更新