Skip to content

Support GITHUB_REPOSITORY #3556

@austindrenski

Description

@austindrenski

Describe the feature or problem you’d like to solve

GitHub Actions sets the GITHUB_REPOSITORY environment variable, but gh only reads the GH_REPO environment variable.

This means that workflows using gh without an actions/checkout step have to set the GH_REPO environment variable:

jobs:
- name: Count PRs
  env:
    GH_REPO: ${{ env.GITHUB_REPOSITORY }}
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  run: gh pr list --json number --jq length

Proposed solution

Read GITHUB_REPOSITORY when GH_REPO is not set, similar to the behavior for {GH,GITHUB}_TOKEN (see: #1229, #2388).

 jobs:
 - name: Count PRs
   env:
-    GH_REPO: ${{ env.GITHUB_REPOSITORY }}
     GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
   run: gh pr list --json number --jq length

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions