File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1- from datetime import datetime , MINYEAR
1+ import os
2+ from datetime import datetime , MINYEAR
23from github import Github , GitRelease , Repository , GithubException
34
45def get_latest_github_repo_version (repo ):
5- client = Github ()
6+ # check for a github token that may be used alongside the codeql cli to upload github results
7+ # this will limit rate limting 403 errors on checking codeql versions, as the request will be authenticated if possible.
8+ # by default codeql uses env var "GITHUB_TOKEN" to authenticate
9+ # https://codeql.github.com/docs/codeql-cli/manual/github-upload-results/
10+ access_token = os .getenv ('GITHUB_TOKEN' )
11+ client = Github (access_token ) if access_token != None else Github ()
612 repo = client .get_repo (repo )
713 releases = repo .get_releases ()
814 latest_release = get_latest_github_release (releases )
Original file line number Diff line number Diff line change @@ -38,12 +38,13 @@ def setup():
3838 # check version and download the latest version
3939 get_latest_codeql (args )
4040 logger .info ("End setup..." )
41+
4142def get_latest_codeql (args ):
4243 codeql = CodeQL (CODEQL_HOME )
43- # what version do we have?
44+ current_installed_version = codeql .get_current_local_version ()
45+ logger .info (f'Current codeql version: { current_installed_version } ' )
46+ # ensure we only query for the latest codeql cli version if we might actually update it
4447 if args .check_latest_cli :
45- current_installed_version = codeql .get_current_local_version ()
46- logger .info (f'Current codeql version: { current_installed_version } ' )
4748 latest_online_version = codeql .get_latest_codeql_github_version ()
4849 if current_installed_version != latest_online_version .title :
4950 # we got a newer version online, download and install it
You can’t perform that action at this time.
0 commit comments