Last day I was struggling to download a GitHub artifact. Tried with invoke-webrequest, web session and even with curl. After reading the GitHub documentation, it seems to be possible with the GitHub API.
The only requirement is that you have a GitHub connection token. Read the following article about how to create a GitHub connection token.
Below a sample script how to download a GitHub artifact.
1 2 3 4 5 |
$baseApi = 'https://api.github.com/repos/username/reponame/actions/artifacts/someid/zip' $dest = "c:\temp\someartifact.zip" $connectionToken = 'ghp_################' $base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)")) Invoke-RestMethod -Uri $uri -Headers @{authorization = "Basic $base64AuthInfo"} -Method Get -outfile $dest |