Skip to content

kenyonj/mark-ready-when-ready

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Mark Ready When Ready

A GitHub Action that automatically marks a draft pull request as ready for review once all required checks pass.

How it works

  1. You open a draft PR and add a trigger label (default: Mark Ready When Ready)
  2. This action watches for all required checks to complete successfully
  3. It pauses briefly, then watches again to catch any late-arriving checks
  4. It verifies results via the GitHub GraphQL API (paginated, handles large check suites)
  5. It confirms the PR has no merge conflicts
  6. If everything looks good, it marks the PR as ready for review and removes the label

This is especially useful for repos with long CI suites — open your PR as a draft, slap on the label, and walk away. The PR will be marked ready for review only when CI is fully green.

Usage

name: Mark PR Ready When Ready

on:
  pull_request:
    types: [opened, edited, labeled, unlabeled, synchronize]

permissions:
  checks: read
  contents: write
  pull-requests: write
  statuses: read

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
  cancel-in-progress: true

jobs:
  mark-ready:
    name: Mark as ready after successful checks
    runs-on: ubuntu-latest
    if: |
      contains(github.event.pull_request.labels.*.name, 'Mark Ready When Ready') &&
      github.event.pull_request.draft == true
    steps:
      - name: Mark ready when ready
        uses: kenyonj/mark-ready-when-ready@v1
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}

Important: The workflow must include contents: write — without it, GITHUB_TOKEN cannot call the markPullRequestReadyForReview GraphQL mutation and will fail with Resource not accessible by integration.

Using a GitHub App token

For organizations or repos where GITHUB_TOKEN permissions are restricted by policy, you can use a GitHub App token instead:

    steps:
      - name: Generate token
        id: generate-token
        uses: actions/create-github-app-token@v2
        with:
          app-id: ${{ secrets.APP_ID }}
          private-key: ${{ secrets.APP_PRIVATE_KEY }}

      - name: Mark ready when ready
        uses: kenyonj/mark-ready-when-ready@v1
        with:
          github-token: ${{ steps.generate-token.outputs.token }}

Inputs

Input Required Default Description
github-token Yes Token with permission to read checks and write to pull requests
label No Mark Ready When Ready The label that triggers the action
pause-seconds No 20 Seconds to pause between verification rounds (catches late-arriving checks)
remove-label No true Whether to remove the trigger label after marking the PR ready

Outputs

Output Description
result ready, failing-checks, conflicting, or skipped
failing-checks Names of required checks that failed (empty string if all passed)

Required permissions

The workflow calling this action needs these permissions for GITHUB_TOKEN:

permissions:
  checks: read
  contents: write       # required for markPullRequestReadyForReview
  pull-requests: write
  statuses: read

Note: contents: write is required even though the action doesn't modify repository contents. Without it, GITHUB_TOKEN cannot call the markPullRequestReadyForReview GraphQL mutation.

Verification strategy

The action uses a "trust but verify" approach:

  1. gh pr checks --watch watches for required checks to complete
  2. A configurable pause catches checks that are re-triggered or start late
  3. gh pr checks --watch runs again to confirm everything is still green
  4. A GraphQL query independently verifies that no required check suites have failing conclusions (ACTION_REQUIRED, TIMED_OUT, CANCELLED, FAILURE, STARTUP_FAILURE) and no required commit statuses are in a FAILURE state
  5. The mergeable state is checked to ensure the PR doesn't have conflicts

This multi-layered approach prevents marking a PR as ready when there are transient or late-arriving failures.

License

MIT

About

GitHub Action that automatically marks a draft PR as ready for review when all required checks pass

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors