@@ -169,46 +169,47 @@ def get_activity(
169169 # We have just org
170170 search_query = f"user:{ org } "
171171
172- if not auth :
173- if "GITHUB_ACCESS_TOKEN" in os .environ :
174- # Access token is stored in a local environment variable so just use this
175- print (
176- "Using GH access token stored in `GITHUB_ACCESS_TOKEN`." ,
177- file = sys .stderr ,
178- )
179- auth = os .environ .get ("GITHUB_ACCESS_TOKEN" )
180- if auth == "" :
181- raise ValueError ("GITHUB_ACCESS_TOKEN exists, but it is empty..." )
182-
183- else :
184- # Attempt to use the gh cli if installed
185- try :
186- p = run (["gh" , "auth" , "token" ], text = True , capture_output = True )
187- auth = p .stdout .strip ()
188- except CalledProcessError :
189- print (
190- ("gh cli has no token. Login with `gh auth login`" ),
191- file = sys .stderr ,
192- )
193- except FileNotFoundError :
172+ if auth is None :
173+ for kind in ["GITHUB_ACCESS_TOKEN" , "GHA_ACCESS_TOKEN" ]:
174+ if kind in os .environ :
175+ # Access token is stored in a local environment variable so just use this
194176 print (
195- (
196- "gh cli not found, so will not use it for auth. To download, "
197- "see https://cli.github.com/"
198- ),
177+ "Using GH access token stored in `GITHUB_ACCESS_TOKEN`." ,
199178 file = sys .stderr ,
200179 )
201- # We can't use this without auth because we hit rate limits immediately
202- if auth is None :
203- raise ValueError (
204- "Either the environment variable GITHUB_ACCESS_TOKEN or the "
205- "--auth flag or must be used to pass a Personal Access Token "
206- "needed by the GitHub API. You can generate a token at "
207- "https://github.com/settings/tokens/new. Note that while "
208- "working with a public repository, you don’t need to set any "
209- "scopes on the token you create. Alternatively, you may log-in "
210- "via the GitHub CLI (`gh auth login`)."
180+ auth = os .environ .get (kind )
181+ if auth == "" :
182+ raise ValueError (f"Found { kind } , but it is empty..." )
183+
184+ if auth is None :
185+ # Attempt to use the gh cli if installed
186+ try :
187+ p = run (["gh" , "auth" , "token" ], text = True , capture_output = True )
188+ auth = p .stdout .strip ()
189+ except CalledProcessError :
190+ print (
191+ ("gh cli has no token. Login with `gh auth login`" ),
192+ file = sys .stderr ,
193+ )
194+ except FileNotFoundError :
195+ print (
196+ (
197+ "gh cli not found, so will not use it for auth. To download, "
198+ "see https://cli.github.com/"
199+ ),
200+ file = sys .stderr ,
211201 )
202+ # We can't use this without auth because we hit rate limits immediately
203+ if auth is None :
204+ raise ValueError (
205+ "Either the environment variable GITHUB_ACCESS_TOKEN or the "
206+ "--auth flag or must be used to pass a Personal Access Token "
207+ "needed by the GitHub API. You can generate a token at "
208+ "https://github.com/settings/tokens/new. Note that while "
209+ "working with a public repository, you don’t need to set any "
210+ "scopes on the token you create. Alternatively, you may log-in "
211+ "via the GitHub CLI (`gh auth login`)."
212+ )
212213
213214 # Figure out dates for our query
214215 since_dt , since_is_git_ref = _get_datetime_and_type (org , repo , since , auth )
0 commit comments