name: draft-limit
# Closes a draft pull request when its author already has another open draft,
# so an outside contributor can't leave a pile of drafts to triage. Maintainers
# and bots are exempt. See jdx/workflows for the workflow implementation.
on:
# Fork pull requests only get a write token under pull_request_target, which
# the shared workflow needs to comment and close. It never checks out or runs
# the pull request's code.
pull_request_target:
types:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
jobs:
draft-limit:
permissions:
pull-requests: write # comment on and close the extra draft
uses: jdx/workflows/.github/workflows/draft-limit.yml@4c952564543dd54d60f15ef4062af7fb60c5561d # v1.1.0
with:
max_drafts: 1