Created
September 21, 2018 22:48
-
-
Save umohi/bfc7ad9a845fc10289c03d532e3d2c2f to your computer and use it in GitHub Desktop.
use curl to download release artifact from github private repository
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in order to download release artifacts from github, you have to first retreive the | |
# list of asset URLs using the github repo REST API. Use the asset URL to download | |
# the artifact as a octet-stream data stream. You will need to get an access token | |
# from "settings -> developer settings -> personal access tokens" on the github UI | |
#!/bin/bash -e | |
owner="MY_ORG_NAME" | |
repo="MY_REPO_NAME" | |
tag="ARTIFACT_TAG" | |
artifact="ARTIFACT_NAME" | |
token="MY_ACCESS_TOKEN" | |
list_asset_url="https://api.github.com/repos/${owner}/${repo}/releases/tags/${tag}?access_token=${token}" | |
# get url for artifact with name==$artifact | |
asset_url=$(curl "${list_asset_url}" | jq ".assets[] | select(.name==\"${artifact}\") | .url" | sed 's/\"//g') | |
# download the artifact | |
curl -vLJO -H 'Accept: application/octet-stream' \ | |
"${asset_url}?access_token=${token}" |
Based on @thenets work, I extended his script with GITHUB_TOKEN support, please check - https://gist.github.com/frozer/6dcdf9a901f32688c4e89163a65b17bd
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on this work, I created a dedicated script:
https://github.com/thenets/bash-helpers/blob/main/scripts/github-release-downloader.sh
Example of usage: