Fix fetching draft releases from GitHub Actions
When using GITHUB_TOKEN in Actions, the permissions on a repository are null and therefore we can't check whether the viewer has push access or not. The solution is to unconditionally check for draft releases instead of trying to be smart about it. Draft releases are going to be on top, so we don't have to paginate through all releases in a repository.
This commit is contained in:
parent
4425365004
commit
c667a0bc49
1 changed files with 3 additions and 10 deletions
|
|
@ -133,11 +133,7 @@ func FetchRelease(httpClient *http.Client, baseRepo ghrepo.Interface, tagName st
|
|||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == 404 {
|
||||
if canPush, err := api.CanPushToRepo(httpClient, baseRepo); err == nil && canPush {
|
||||
return FindDraftRelease(httpClient, baseRepo, tagName)
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return FindDraftRelease(httpClient, baseRepo, tagName)
|
||||
}
|
||||
|
||||
if resp.StatusCode > 299 {
|
||||
|
|
@ -230,11 +226,8 @@ func FindDraftRelease(httpClient *http.Client, baseRepo ghrepo.Interface, tagNam
|
|||
return &r, nil
|
||||
}
|
||||
}
|
||||
|
||||
if len(releases) < perPage {
|
||||
break
|
||||
}
|
||||
page++
|
||||
//nolint:staticcheck
|
||||
break
|
||||
}
|
||||
|
||||
return nil, errors.New("release not found")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue