pantheon.updateScript: support an OAUTH_TOKEN

Sometimes I get rate limited.
This commit is contained in:
worldofpeace 2019-11-25 15:56:49 -05:00
parent d04e10b3d7
commit 0e7b294777

View File

@ -114,7 +114,26 @@ EOF
function get_latest_tag ( ) {
repo_name="$1"
curl --silent --show-error --fail -X GET "https://api.github.com/repos/elementary/$repo_name/releases/latest" | jq -r '.tag_name'
OAUTH_TOKEN=$(printenv OAUTH_TOKEN)
if [ -n "$OAUTH_TOKEN" ]; then
curl \
--silent \
--show-error \
--fail \
-X GET \
--header "Authorization: token $OAUTH_TOKEN" \
"https://api.github.com/repos/elementary/$repo_name/releases/latest" \
| jq -r '.tag_name'
else
curl \
--silent \
--show-error \
--fail \
-X GET \
"https://api.github.com/repos/elementary/$repo_name/releases/latest" \
| jq -r '.tag_name'
fi
}
#