admin管理员组文章数量:1355600
Looking at this documentation I can use curl
version of the provided example:
curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer GITHUB_CODE" -H "X-GitHub-Api-Version: 2022-11-28" --output c:\\temp\\artifact.zip
Notice: output
argument. This code downloads the artifacts and saves it as a zip file. However I want to use GitHub CLI for this purpose (login has been successful):
gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/USER/REPO/actions/artifacts/ARTIFACT_ID/zip
As far as I understand, this code just prints the text representation of the binary file since I see a plain text in the output which is related to my artifacts. But how to save this output into the binary zip file? Just redirecting output gh .. > res.zip
doesn't work (saves a corrupted file). I also don't see arguments in the gh
binary that can help with this
Looking at this documentation I can use curl
version of the provided example:
curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer GITHUB_CODE" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github/repos/USER/REPO/actions/artifacts/ARTIFACT_ID/zip --output c:\\temp\\artifact.zip
Notice: output
argument. This code downloads the artifacts and saves it as a zip file. However I want to use GitHub CLI for this purpose (login has been successful):
gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/USER/REPO/actions/artifacts/ARTIFACT_ID/zip
As far as I understand, this code just prints the text representation of the binary file since I see a plain text in the output which is related to my artifacts. But how to save this output into the binary zip file? Just redirecting output gh .. > res.zip
doesn't work (saves a corrupted file). I also don't see arguments in the gh
binary that can help with this
1 Answer
Reset to default 1 +50At the moment, it is not possible to redirect the output of the gh api
call to download artifacts as a zip file. An alternative is to use the gh run download
command to download the artifacts.
By default, this command downloads the latest artifact created and uploaded through GitHub Actions. You can specify the <run-id>
to select an artifact from a specific workflow run. You can also filter the artifacts by name by specifying the -n
or --name
option.
# Download a specific artifact within a run
$ gh run download <run-id> -n <name>
You can also specify the -D
or --dir
option to specify the directory where the artifacts will be downloaded.
Reference: Docs.
Update: You can use the -R
or --repo
option to specify another repo from which you want to download the artifacts.
Options inherited from parent commands
-R, --repo <[HOST/]OWNER/REPO>
Select another repository using the [HOST/]OWNER/REPO format
本文标签: Download artifacts from a different GitHub repo with gh cliStack Overflow
版权声明:本文标题:Download artifacts from a different GitHub repo with gh cli - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744019172a2576896.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论