mirror of
https://github.com/Azure/setup-helm.git
synced 2025-11-07 21:16:57 +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:
parent
b70d33f56d
commit
16399bb4df
1 changed files with 4 additions and 4 deletions
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue