chore: automate marking as draft on requesting changes (#6729)
This commit is contained in:
parent
c2fd12238f
commit
bb0c1b3723
60
.github/workflows/mark-as-draft-on-requesting-changes.yml
vendored
Normal file
60
.github/workflows/mark-as-draft-on-requesting-changes.yml
vendored
Normal 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"
|
||||||
Loading…
Reference in New Issue
Block a user