Skip to content

gh pr edit --add-reviewer requires checkout of a very specific branch #10071

@TWiStErRob

Description

@TWiStErRob

Describe the bug

Latest gh on GHA at the moment.
https://github.com/cli/cli/releases/tag/v2.63.2 was released 7 days ago.

Steps to reproduce the behavior

  1. We're trying to add a team reviewer:
on:
  pull_request:
    types:
      - edited
jobs:
  job:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - run: gh pr edit "${PR_NUMBER}" --add-reviewer "${REVIEWER_TEAM}"
        env:
          GH_TOKEN: ${{ github.token }}
          GH_REPO: ${{ github.repository }}
          REVIEWER_TEAM: my-org/my-team
          PR_NUMBER: ${{ github.event.pull_request.number }}
  1. The output is:
could not determine current branch: failed to run git: fatal: not a git repository (or any of the parent directories): .git

even though we clearly defined the repository with GH_REPO, so gh should go into auto-detect mode.

  1. Add a checkout step
- uses: actions/checkout@v4
  1. The output is:
could not determine current branch: failed to run git: not on any branch
  1. Configure the checkout step
- uses: actions/checkout@v4
  with:
    ref: ${{ github.event.pull_request.head.ref }}
  1. Finally got a proper error message that we need permissions for organisation.teams -> https://github.com/orgs/community/discussions/113519

Expected vs actual behavior

Expected behavior would be that we're not forced to clone the repo just to get the branch name, which is seemingly not even used in the command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-prrelating to the gh pr commandmore-info-neededMore info needed from user/contributorneeds-triageneeds to be reviewed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions