Skip to content

Instantly share code, notes, and snippets.

@polsala
Created June 14, 2023 07:12
Show Gist options
  • Save polsala/f44d5f6f09b45da6099ff6e8e2a5e9d8 to your computer and use it in GitHub Desktop.
Save polsala/f44d5f6f09b45da6099ff6e8e2a5e9d8 to your computer and use it in GitHub Desktop.
Download assets from last release of private/public github repo [only custom assets]
#!/bin/bash
export GITHUB_TOKEN=******************************
export OWNER=********
export REPO=******
EE=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/$OWNER/$REPO/releases/latest | grep https://api.github.com/repos/$OWNER/$REPO/releases/assets/. | cut -d : -f 2,3 | tr -d \" | tr -d ,)
for URL in $EE
do
echo $URL
name=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" $URL | grep '"name":.' | cut -d : -f 2,3 | tr -d \" | tr -d ,)
curl -L -o $name -H "Accept: application/octet-stream" -H "Authorization: Bearer $GITHUB_TOKEN" -H "X-GitHub-Api-Version: 2022-11-28" $URL
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment