Skip to content

Commit

Permalink
Merge pull request #9 from nolar/pagination
Browse files Browse the repository at this point in the history
Paginate the releases of K3s
  • Loading branch information
nolar authored Jun 9, 2021
2 parents b24727a + b997637 commit 5c8800f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ fi

# Fetch all K3s versions usable for the specified partial version.
# Even if the version is specific and complete, assume it is possibly partial.
url="${GITHUB_API_URL}/repos/${REPO}/releases?per_page=999"
releases=$(curl --silent --fail --location "${authz[@]-}" "$url")
versions=$(jq <<< "$releases" '.[] | select(.prerelease==false) | .tag_name')
# 2-3 pages are enough to reach v0 while not depleting the GitHub API limits.
versions=""
for page in 1 2 ; do
url="${GITHUB_API_URL}/repos/${REPO}/releases?per_page=999&page=${page}"
releases=$(curl --silent --fail --location "${authz[@]-}" "$url")
versions+=$(jq <<< "$releases" '.[] | select(.prerelease==false) | .tag_name')
versions+=$'\n'
done
versions_sorted=$(sort <<< "$versions" --field-separator=- --key=1,1rV --key=2,2rV)

echo "::group::All available K3s versions (newest on top)"
Expand Down

0 comments on commit 5c8800f

Please sign in to comment.