diff --git a/files/update_mastodon.sh b/files/update_mastodon.sh index c162c0e..d0f948b 100755 --- a/files/update_mastodon.sh +++ b/files/update_mastodon.sh @@ -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