4
0
Fork 0
mirror of https://github.com/Azure/setup-helm.git synced 2025-11-08 05:26:56 +00:00

refactor: cleanup GH gql query

This updates the graphql query used to fetch releases by:
- returning only the first 10
- ordering them in reverse by created_at

This is better because it does not rely on the default ordering by the
GitHub graphql API.

Co-authored-by: Pieter Van der Haegen <vdhpieter@outlook.com>
This commit is contained in:
Joe Previte 2022-10-25 08:24:37 -07:00
parent b70d33f56d
commit 16399bb4df
No known key found for this signature in database
GPG key ID: 2C91590C6B742C24

View file

@ -59,7 +59,7 @@ export async function getLatestHelmVersion(): Promise<string> {
` `
{ {
repository(name: "helm", owner: "helm") { repository(name: "helm", owner: "helm") {
releases(last: 100) { releases(first: 100, orderBy: {field: CREATED_AT, direction: DESC}) {
nodes { nodes {
tagName tagName
} }
@ -68,9 +68,9 @@ export async function getLatestHelmVersion(): Promise<string> {
} }
` `
) )
const releases: string[] = repository.releases.nodes const releases: string[] = repository.releases.nodes.map(
.reverse() (node: {tagName: string}) => node.tagName
.map((node: {tagName: string}) => node.tagName) )
const latestValidRelease = releases.find((tag) => isValidVersion(tag)) const latestValidRelease = releases.find((tag) => isValidVersion(tag))
if (latestValidRelease) return latestValidRelease if (latestValidRelease) return latestValidRelease
} catch (err) { } catch (err) {