cli: Accessing draft releases is not possible using GITHUB_TOKEN in Actions
Reported by @simonbrunel in https://github.com/cli/cli/discussions/3029#discussioncomment-399296
To find a draft release by its tag name, we have to iterate through all releases and look into the draft ones, since there is no API endpoint to directly fetch a draft release. To avoid doing this unnecessarily when a release isn’t a draft, we first check whether the viewer has write access to the repo to determine whether they can have access to drafts: https://github.com/cli/cli/pull/1552
This doesn’t work with the generated GITHUB_TOKEN in GitHub Actions, since the viewerPermission object is null, likely due to the nature of GITHUB_TOKEN being a server-to-server integration token.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 15 (5 by maintainers)
Commits related to this issue
- Switch back to hub because of gh + Actions bug with draft releases https://github.com/cli/cli/issues/3037 — committed to cli/cli by mislav 3 years ago
@mislav It was working properly good until yesterday to me, some repos still working but one of then is having problem when I try to get al releases using GITHUB_TOKEN integration, it is only returning non draft releases. Nothing was changed since the last workflow run ( 2 days ago ). Do you have any other report about it?
This is now fixed on the platform:
gh release listshould include draft releases when using GITHUB_TOKEN generated by GitHub Actions.Reopening! From my testing, it looks like the GraphQL endpoint (which we use at the moment) doesn’t include drafts when listing releases, while the REST does include drafts. Perhaps we should move to the REST endpoint.
~I am 90% sure that the GraphQL endpoint also listed drafts in the past when authenticated with GITHUB_TOKEN. Perhaps this regressed on the platform side at some point?~ I remembered this wrongly.
I am the original author of #5252, and I can confirm that everything seems to work like before again: https://github.com/cli/cli/issues/5252#issuecomment-1054168859
Unless you can still reproduce the issue there was a feature flag enabled that was reverted
https://github.com/release-drafter/release-drafter/issues/1081#issuecomment-1051301374
@mislav Same problem for me, can’t see any draft releases with
GITHUB_TOKENsince at least yesterday.We use a draft to store some artifacts, but cannot reach them with GITHUB_TOKEN; we are forced to use personal token instead.