Skip to content

gh pr ready doesn't work with GitHub Actions' GITHUB_TOKEN secret #8910

Open

Description

@suzuki-shunsuke

Describe the bug

A clear and concise description of what the bug is. Include version by typing gh --version.

$ gh version
gh version 2.46.0 (2024-03-20)
https://github.com/cli/cli/releases/tag/v2.46.0

gh pr ready doesn't work with GitHub Actions' GITHUB_TOKEN secret.

The error message is API call failed: GraphQL: Resource not accessible by integration (markPullRequestReadyForReview).

I found the same issue, but the issue should have already been solved.

Steps to reproduce the behavior

  1. Type this '...'
  2. View the output '....'
  3. See error

Run gh pr ready with GitHub Actions' GITHUB_TOKEN secret.

---
name: test
on: pull_request
jobs:
  test:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - run: gh version
      - run: gh -R "$GITHUB_REPOSITORY" pr ready 1
        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

https://github.com/suzuki-shunsuke/test-gh-pr-ready-with-github-token-secret/actions/runs/8522674476/job/23343382304

Expected vs actual behavior

A clear and concise description of what you expected to happen and what actually happened.

Logs

Paste the activity from your command line. Redact if needed.

Run gh -R "$GITHUB_REPOSITORY" pr ready 1
  gh -R "$GITHUB_REPOSITORY" pr ready 1
  shell: /usr/bin/bash -e {0}
  env:
    GITHUB_TOKEN: ***
API call failed: GraphQL: Resource not accessible by integration (markPullRequestReadyForReview)
Error: Process completed with exit code 1.

https://github.com/suzuki-shunsuke/test-gh-pr-ready-with-github-token-secret/actions/runs/8522616582/job/23343198723?pr=1#step:2:7

Activity

  1. williammartin commented on Apr 2, 2024

    @williammartin
    Member

    What is $GITHUB_REPOSITORY set to? I don't see it configured anywhere.

  2. added
    more-info-neededMore info needed from user/contributor
    and removed on Apr 2, 2024
  3. suzuki-shunsuke commented on Apr 2, 2024

    @suzuki-shunsuke
    Author

    https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables

    $GITHUB_REPOSITORY is a GitHub Actions' default environment variable.

    GITHUB_REPOSITORY The owner and repository name. For example, octocat/Hello-World.

  4. williammartin commented on Apr 2, 2024

    @williammartin
    Member

    Thanks, I don't see any obvious reason why this wouldn't work. Will need to investigate when we have time. In the meantime you'll need to use a PAT. Thanks for the report and the reproduction.

  5. added and removed
    more-info-neededMore info needed from user/contributor
    on Apr 2, 2024
  6. alth-ansys commented on Feb 17, 2026

    @alth-ansys

    Hey,

    I was facing the same issue in our repo.

    The PR was created via a cli in a github cron by github-actions [bot]. The cron does a workflow_dispatch to a worfklow which eventually tried to pass the PR as ready.

    The job was in essence like this:

    job_name:
       runs-on: worker
       permissions:
         contents: read
         pull-requests: write
       steps:
         - uses: actions/checkout@v6
         - name: Mark PR as ready for review
           env:
             GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
           run: |
             gh pr ready PR_NUMBER
    

    Running this triggered

    API call failed: GraphQL: Resource not accessible by integration (markPullRequestReadyForReview)

    Similar output when trying to pass a ready PR to draft gh pr ready PR_NUMBER --undo:

    API call failed: GraphQL: Resource not accessible by integration (convertPullRequestToDraft)

    It was slightly surprising but changing the contents permissions to write made the gh command succeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-investigationCLI team needs to investigate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions