This repo contains a reproduction of a weird behaviour encountered using GitHub CLI in an action.
From the API docs at https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#list-releases, a token with the permission set contents:read
should suffice.
As this repo showcases, if the token has the permission contents:read
, the gh release list --json name
command returns an empty array; if the token has the permission contents:write
, the gh release list --json name
command returns the expected releases.
Example using HTTPS:
git clone https://github.com/<your_username>/releases-repro
git add test.txt
git commit -m "testing stuff"
git push
git tag -a v0.0.1 -m "Test release"
git push origin v0.0.1
At this point the workflow should create a draft release automatically.
Navigate to https://github.com/<your_username>/releases-repro/actions/workflows/list-releases.yml