Skip to content

Instantly share code, notes, and snippets.

@MichaelChirico
Last active November 17, 2023 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MichaelChirico/d5a1a0d864864e0d30f24e3eb87afecf to your computer and use it in GitHub Desktop.
Save MichaelChirico/d5a1a0d864864e0d30f24e3eb87afecf to your computer and use it in GitHub Desktop.
GHA results
library(jsonlite)
library(data.table)
headers <- shQuote(c(
"-H", "Accept: application/vnd.github+json",
"-H", sprintf("Authorization: Bearer %s", Sys.getenv("GITHUB_PAT")),
"-H", "X-GitHub-Api-Version: 2022-11-28"
))
url_fmt <- "https://api.github.com/repos/r-lib/lintr/actions/runs?per_page=%d&page=%d"
per_page <- 100L
get_page <- \(page) fromJSON(system2("curl", c("-s", "-L", headers, sprintf(url_fmt, per_page, page)), stdout=TRUE))
runs <- list()
page <- 1L
n_pages <- Inf
while (page < n_pages) {
cat(sprintf("\rpage %d of %.0f...", page, n_pages))
result <- get_page(page)
if (is.infinite(n_pages)) {
n_pages <- ceiling(result$total_count / per_page)
}
runs[[page]] <- result$workflow_runs
page <- page + 1L
}
cat("\n")
runs <- rbindlist(lapply(runs, as.data.table))
runs = runs[, .SD, .SDcols = !patterns("^(head_)?repository|url$")]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment