This GitHub action sets a PR to draft (if not already so)
This action converts a pull request to draft status using the GitHub GraphQL API. If the PR is already a draft, no action is taken.
Required The pull request number to convert to draft.
Required GitHub token with permissions to modify pull requests. Defaults to ${{ github.token }}.
Required Permissions:
pull-requests: write- Required to modify pull request statuscontents: write- Required for the GraphQL mutation to operate
name: Convert to Draft on Changes Requested
on:
pull_request_review:
types: [submitted]
jobs:
convert-to-draft:
runs-on: ubuntu-latest
if: github.event.review.state == 'changes_requested'
permissions:
pull-requests: write
contents: write
steps:
- name: Convert PR to Draft
uses: Huxelerate/action-draft-pr@v1
with:
pr-number: ${{ github.event.pull_request.number }}
github-token: ${{ secrets.GITHUB_TOKEN }}- Takes a PR number as input
- Checks if the PR is already in draft status
- If not, uses the GitHub GraphQL
convertPullRequestToDraftmutation to convert it - Reports success or failure
MIT