MissingGhRepo¶
GH_REPO or checkout is required for using the gh CLI tool.
Defined by MissingGhRepoRule which supports workflows, actions in the "Default" ruleset.
Description¶
Using the gh CLI tool requires a GitHub repository to be cloned or defined in an environment variable.
GH_REPO: specify the GitHub repository in the[HOST/]OWNER/REPOformat for commands that otherwise operate on a local repository. -- gh help environment
For most commands there's also a --repo or -R flag that can be used to specify the repository.
-R,--repo<[HOST/]OWNER/REPO>Select another repository using the[HOST/]OWNER/REPOformat -- gh pr
This is not supported yet and will be reported as a violation: https://github.com/TWiStErRob/net.twisterrob.ghlint/issues/280
The rationale behind this is that we're running the gh CLI tool in a GitHub Actions environment,
which is usually coupled with a repository hosting the workflow.
Since this is an implicit context, it's more natural to use GH_REPO: ${{ github.repository }}.
In rare cases when we need to operate on a foreign repository,
we might use --repo, but we can still use the same GH_REPO approach.
Compliant examples¶
Compliant example #1¶
GH_REPO is defined.
example.ymlon: push jobs: example: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: gh pr list env: GH_TOKEN: ${{ github.token }} GH_REPO: ${{ github.repository }}
Compliant example #2¶
Code is cloned, so repo is known.
example.ymlon: push jobs: example: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: gh pr list env: GH_TOKEN: ${{ github.token }}
Non-compliant example¶
Repository context is not known.
example.ymlon: push jobs: example: runs-on: ubuntu-latest steps: - run: gh pr list env: GH_TOKEN: ${{ github.token }}
- Line 6: Step[#0] in Job[example] should see
GH_REPOenvironment variable or have a repository cloned.