How can I use the GitHub CLI to download a release from a private repo?

203 views Asked by At

I'm trying to download assets from a release on a private repository.

My current code would be:

run: gh release download release -R Hostname/RepoName -D

This only works if the repository is public. Is there a way to get the assets from a private repository?

1

There are 1 answers

0
Matteo On

I think you should provide an Access token of the private repo/orgs. From the doc of the CLI tool:

To use gh in GitHub Actions, add GH_TOKEN: ${{ github.token }} to "env".

something like:

      - name: Download release from private repo
        env:
          GH_TOKEN: ${{ secrets.GH_API_TOKEN }}
        run: gh release download release -R Hostname/RepoName -D .

where GH_API_TOKEN is a valid PAT for access to the Hostname/RepoName repo.