Skip to content

This GitHub action sets a PR to draft (if not already so)

License

Notifications You must be signed in to change notification settings

Huxelerate/action-draft-pr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

action-draft-pr

This GitHub action sets a PR to draft (if not already so)

Description

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.

Inputs

pr-number

Required The pull request number to convert to draft.

github-token

Required GitHub token with permissions to modify pull requests. Defaults to ${{ github.token }}.

Required Permissions:

  • pull-requests: write - Required to modify pull request status
  • contents: write - Required for the GraphQL mutation to operate

Example Usage

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 }}

How it Works

  1. Takes a PR number as input
  2. Checks if the PR is already in draft status
  3. If not, uses the GitHub GraphQL convertPullRequestToDraft mutation to convert it
  4. Reports success or failure

License

MIT

About

This GitHub action sets a PR to draft (if not already so)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •