Add pagination
This commit is contained in:
parent
f3a869a0de
commit
888607d193
1 changed files with 10 additions and 2 deletions
|
@ -50,8 +50,16 @@ done
|
|||
if [ "${tag}" == "latest" ]; then
|
||||
tag=$(curl -L -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${token}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/mastodon/mastodon/releases/latest | jq '.tag_name')
|
||||
else
|
||||
releases=$(curl -L -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${token}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/mastodon/mastodon/releases | jq '.[]|.tag_name')
|
||||
if ! echo "${releases}" | pgrep "${tag}"; then
|
||||
next_page=https://api.github.com/repos/mastodon/mastodon/releases
|
||||
releases_file=$(mktemp /tmp/tmp.XXXX)
|
||||
while [ -z "${next_page}" ]
|
||||
do
|
||||
tmpfile=$(mktemp /tmp/tmp.XXXXX)
|
||||
releases=$(curl -L -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${token}" -H "X-GitHub-Api-Version: 2022-11-28" "${next_page}" | jq '.[]|.tag_name' 2> "${tmpfile}")
|
||||
echo "${releases}" >> "${releases_file}"
|
||||
next_page=$(grep '< link: ' "${tmpfile}" | sed 's/< link: //g' | sed 's/, /\n/g' | grep 'rel="next"' | grep -o 'https://[^>]*')
|
||||
done
|
||||
if ! pgrep "${tag}" "${releases_file}"; then
|
||||
printf "The tag '%s' is not part of the releases:\n%s" "${tag}" "${releases}"
|
||||
exit 1
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue