Skip to content

Commit 346185e

Browse files
committed
Use a better API to check organization membership.
1 parent 3346397 commit 346185e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

internal/push/push.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ func (pushService *pushService) createRepository() (*github.Repository, error) {
9999
}
100100
}
101101

102-
_, response, err = pushService.githubEnterpriseClient.Organizations.GetOrgMembership(pushService.ctx, user.GetLogin(), pushService.destinationRepositoryOwner)
103-
if err != nil && (response == nil || response.StatusCode != http.StatusNotFound) {
102+
_, response, err = pushService.githubEnterpriseClient.Organizations.IsMember(pushService.ctx, user.GetLogin(), pushService.destinationRepositoryOwner)
103+
if err != nil {
104104
return nil, errors.Wrap(err, "Failed to check membership of destination organization.")
105105
}
106-
if err != nil && githubapiutil.HasAnyScope(response, "site_admin") {
106+
if (response.StatusCode == http.StatusFound || response.StatusCode == http.StatusNotFound) && githubapiutil.HasAnyScope(response, "site_admin") {
107107
log.Debugf("No access to destination organization. Switching to impersonation token for %s...", pushService.actionsAdminUser)
108108
impersonationToken, _, err := pushService.githubEnterpriseClient.Admin.CreateUserImpersonation(pushService.ctx, pushService.actionsAdminUser, &github.ImpersonateUserOptions{Scopes: []string{minimumRepositoryScope, "workflow"}})
109109
if err != nil {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy