saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
13.98k stars 5.47k forks source link

[BUG] tools get_github_token uses non-existent 'token' for gh auth #66620

Closed dmurphy18 closed 3 weeks ago

dmurphy18 commented 3 weeks ago

Description tools get_github_token uses non-existent 'token' for gh auth on line https://github.com/saltstack/salt/blame/332379d06af6bbccb4e881f572042debad6de5e6/tools/utils/gh.py#L261

Found this on a clean rebuild of a laptop, and hitting invalid line due to no GITHUB_TOKEN set.

Steps to Reproduce the behavior tools ts setup --platform linux --slug rockylinux-9 --pr 66218 --pkg 2>&1 | tee ~/mytest.log

Expected behavior

Screenshots For example:

david@david-XPS-15-9570:~/devcode/dgm_salt_3006/salt$ tools ts setup --platform linux --slug rockylinux-9 --pr 66218 --pkg 2>&1 | tee ~/mytest.log
[14:05:53] Consider this in preliminary support. There are most likely things to iron out still.                                                                                                                                                                                             
           Discovering the run_id(branch=None, nightly=None, pr=66218, repository='saltstack/salt')                                                                                                                                                                                          
DGM ctx.run cmdline '('/usr/bin/gh', 'auth', 'token')', check 'False', timeout_secs 'None', capture 'True', interactive 'False', kwargs '{}
DGM ctx.run return 'CompletedProcess(args=('/usr/bin/gh', 'auth', 'token'), returncode=1, stdout=b'unknown command "token" for "gh auth"\n\nUsage:  gh auth <command> [flags]\n\nAvailable commands:\n  login\n  logout\n  refresh\n  setup-git\n  status\n', stderr=b'')'
           Failed to get the GitHub token from the 'gh' CLI tool                                                                                                                                                                                                                             
[14:05:54] Searching for workflow runs for HEAD SHA: f2d224ec4c4a746fb1125fb98834da0c4e808fc1                                                                                                                                                                                                
           Discovered 1 workflow runs for HEAD SHA f2d224ec4c4a746fb1125fb98834da0c4e808fc1                                                                                                                                                                                                  
           Discovered run_id: 9372203822                                                                                                                                                                                                                                                     
           Searching for artifact salt-*-onedir-linux-x86_64.tar.xz from run_id 9372203822 in repository saltstack/salt ...                                                                                                                                                                  
DGM ctx.run cmdline '('/usr/bin/gh', 'auth', 'token')', check 'False', timeout_secs 'None', capture 'True', interactive 'False', kwargs '{}
DGM ctx.run return 'CompletedProcess(args=('/usr/bin/gh', 'auth', 'token'), returncode=1, stdout=b'unknown command "token" for "gh auth"\n\nUsage:  gh auth <command> [flags]\n\nAvailable commands:\n  login\n  logout\n  refresh\n  setup-git\n  status\n', stderr=b'')'
           Failed to get the GitHub token from the 'gh' CLI tool                                                                                                                                                                                                                             
           Downloading artifacts requires being authenticated to GitHub.                                                                                                                                                                                                                     
           Either set 'GITHUB_TOKEN' to a valid token, or configure the 'gh' tool such that 'gh auth token' returns a token.                                                                                                                                                                 

david@david-XPS-15-9570:~/devcode/dgm_salt_3006/salt$ gh auth --help
Manage gh's authentication state.

USAGE
  gh auth <command> [flags]

CORE COMMANDS
  login:         Authenticate with a GitHub host
  logout:        Log out of a GitHub host
  refresh:       Refresh stored authentication credentials
  setup-git:     Configure git to use GitHub CLI as a credential helper
  status:        View authentication status

INHERITED FLAGS
  --help   Show help for command

LEARN MORE
  Use 'gh <command> <subcommand> --help' for more information about a command.
  Read the manual at https://cli.github.com/manual

david@david-XPS-15-9570:~/devcode/dgm_salt_3006/salt$ 

From the gh auth --help, it can be seen that 'token' is not a valid sub-command

Additional context This is using branh 3006.x, but the same line exists in 3007 and master