我维护的一个项目的仓库经常有误开 PR 的用户,每次都要一个个手动关闭,非常麻烦,遂设计了一个匹配提交信息自动关闭 PR 的工作流
此工作流会在检测到提交信息为Update main.go
时自动关闭 PR。
name: PullLint
on:
pull_request_target:
types: [assigned, opened, synchronize, reopened]
jobs:
# This workflow closes invalid PR
close-pr:
name: closepr
# The type of runner that the job will run on
runs-on: ubuntu-latest
permissions: write-all
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Close PR if commit message is "Update main.go"
if: github.event.pull_request.title == 'Update main.go'
uses: superbrothers/close-pull-request@v3
with:
# Optional. Post a issue comment just before closing a pull request.
comment: "Invalid PR."