X Tutup
Skip to content

Commit c667a0b

Browse files
committed
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.
1 parent 4425365 commit c667a0b

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

pkg/cmd/release/shared/fetch.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,7 @@ func FetchRelease(httpClient *http.Client, baseRepo ghrepo.Interface, tagName st
133133
defer resp.Body.Close()
134134

135135
if resp.StatusCode == 404 {
136-
if canPush, err := api.CanPushToRepo(httpClient, baseRepo); err == nil && canPush {
137-
return FindDraftRelease(httpClient, baseRepo, tagName)
138-
} else if err != nil {
139-
return nil, err
140-
}
136+
return FindDraftRelease(httpClient, baseRepo, tagName)
141137
}
142138

143139
if resp.StatusCode > 299 {
@@ -230,11 +226,8 @@ func FindDraftRelease(httpClient *http.Client, baseRepo ghrepo.Interface, tagNam
230226
return &r, nil
231227
}
232228
}
233-
234-
if len(releases) < perPage {
235-
break
236-
}
237-
page++
229+
//nolint:staticcheck
230+
break
238231
}
239232

240233
return nil, errors.New("release not found")

0 commit comments

Comments
 (0)
X Tutup