-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.Rmd
67 lines (58 loc) · 1.78 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
output:
html_document:
self_contained: false
title: "Repository status"
---
```{r include = FALSE}
github <- Sys.getenv("GITHUB_SERVER_URL", "https://github.com")
gen_slug <- Sys.getenv("GITHUB_REPOSITORY")
library(dplyr)
library(purrr)
```
Generated by [`r gen_slug`](`r github`/`r gen_slug`).
```{r echo = FALSE}
all_workflows <- dir("wt", recursive = TRUE)
repo_workflows <- grep("^[^/]+/[^/]+/[^/]+[.]ya?ml$", all_workflows, value = TRUE)
has_push <- function(x) {
if (is.character(x)) {
"push" %in% x
} else {
!is.null(x$push)
}
}
make_slug <- function(slug) {
paste0(
'<a href="', github, "/", slug, '" target="_blank">',
slug,
"</a>",
' <a href="', github, "/", slug, '/actions" target="_blank">',
"(actions)",
"</a>"
)
}
make_badge <- function(slug, name, yaml_name) {
paste0(
'<a href="', github, "/", slug, "/actions/workflows/", yaml_name, '" target="_blank">',
"![", name, "]",
"(https://shields.io/github/actions/workflow/status/", slug, "/", yaml_name, "?label=", name, ")",
"</a>"
)
}
tibble(workflow = repo_workflows) %>%
mutate(contents = map(file.path("wt", workflow), ~ suppressWarnings(yaml::read_yaml(.x, eval.expr = FALSE)))) %>%
mutate(has_push = map_lgl(contents, ~ has_push(.x$on) || has_push(.x$"TRUE"))) %>%
filter(has_push) %>%
mutate(name = map_chr(contents, c("name"))) %>%
mutate(yaml_name = basename(workflow)) %>%
mutate(name = coalesce(name, yaml_name)) %>%
mutate(slug = dirname(workflow)) %>%
add_count(name) %>%
arrange(slug, desc(n), name) %>%
select(slug, name, yaml_name) %>%
group_by(slug) %>%
summarize(badge = paste(make_badge(slug, name, yaml_name), collapse = " ")) %>%
ungroup() %>%
transmute(Repository = make_slug(slug), Badges = badge) %>%
knitr::kable()
```