Merge branch 'improve-existing-action' of https://github.com/actions/delete-package-versions into improve-existing-action

This commit is contained in:
Namrata Jha
2021-12-22 19:18:26 +00:00
committed by GitHub
3 changed files with 85 additions and 12 deletions

View File

@@ -78,7 +78,7 @@ export function finalIds(input: Input): Observable<string[]> {
input.owner,
input.repo,
input.packageName,
RATE_LIMIT,
100,
'',
input.token
).pipe(
@@ -99,6 +99,11 @@ export function finalIds(input: Input): Observable<string[]> {
}
return value.map(info => info.id).slice(0, toDelete)
} else return []
/*
if (toDelete > 0) {
input.numDeleted += toDelete
return value.map(info => info.id).slice(0, toDelete)
} else return []*/
})
)
}

View File

@@ -18,6 +18,39 @@ const mutation = `
}
}`
export interface RateLimitResponse {
viewer: {
login: string
}
ratelimit: {
limit: number
cost: number
remaining: number
resetAt: string
}
}
const ratelimitQuery = `
query {
viewer {
login
}
rateLimit {
limit
cost
remaining
resetAt
}
}`
export async function getRateLimit(token: string): Promise<RateLimitResponse> {
return graphql(token, ratelimitQuery, {
headers: {
Accept: 'application/vnd.github.package-deletes-preview+json'
}
}) as Promise<RateLimitResponse>
}
export function deletePackageVersion(
packageVersionId: string,
token: string