chore: automate marking as draft on requesting changes (#6729)

This commit is contained in:
Frank Elsinga
2026-01-14 11:22:11 +01:00
committed by GitHub
parent c2fd12238f
commit bb0c1b3723
3 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
name: Mark PR as draft when changes are requested
on:
pull_request_review:
types: [submitted]
pull_request:
types: [labeled]
permissions: {}
jobs:
mark-draft:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: read
if: |
(
github.event_name == 'pull_request_review' &&
github.event.review.state == 'changes_requested'
) || (
github.event_name == 'pull_request' &&
github.event.label.name == 'pr:please address review comments'
)
steps:
- name: Add label on requested changes
if: github.event_name == 'pull_request_review'
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
gh issue edit "$PR_NUMBER" \
--repo "$REPO" \
--add-label "pr:please address review comments"
- name: Mark PR as draft
env:
GH_TOKEN: ${{ github.token }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: gh pr ready "$PR_URL" --undo || true
ready-for-review:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.action == 'ready_for_review'
steps:
- name: Update labels for review
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
gh issue edit "$PR_NUMBER" \
--repo "$REPO" \
--remove-label "pr:please address review comments" || true
gh issue edit "$PR_NUMBER" \
--repo "$REPO" \
--add-label "pr:needs review"