19
19
# ' * Provides the markdown to insert a badge into your README
20
20
# '
21
21
# ' @name github_actions
22
+
22
23
# ' @param name For `use_github_action()`: Name of one of the example workflows
23
- # ' from <https://github.com/r-lib/actions/tree/v1/examples>, with or without a
24
- # ' `.yaml` extension, e.g. "pkgdown" or "test-coverage.yaml".
24
+ # ' from <https://github.com/r-lib/actions/tree/v1/examples>. Examples:
25
+ # ' "pkgdown", "check-standard.yaml".
26
+ # '
27
+ # ' For `use_github_actions_badge()`: Name of the workflow's YAML configuration
28
+ # ' file. Examples: "R-CMD-check", "R-CMD-check.yaml".
25
29
# '
26
- # ' For `use_github_actions_badge()`: Specifies the workflow whose status the
27
- # ' badge will report. Usually, this is the `name` keyword that appears in the
28
- # ' workflow `.yaml` file.
30
+ # ' If `name` has no extension, we assume it's `.yaml`.
29
31
# ' @eval param_repo_spec()
30
32
# ' @param url The full URL to a `.yaml` file on GitHub.
31
33
# ' @param save_as Name of the local workflow file. Defaults to `name` or
36
38
# ' about the workflow. Ignored when `url` is `NULL`.
37
39
# ' @inheritParams use_template
38
40
# '
41
+
39
42
# ' @seealso
40
43
# ' * [use_github_file()] for more about `url` format and parsing.
41
44
# ' * [use_tidy_github_actions()] for the standard GitHub Actions used for
42
45
# ' tidyverse packages.
46
+
43
47
# ' @examples
44
48
# ' \dontrun{
45
49
# ' use_github_actions()
@@ -67,13 +71,17 @@ use_github_actions <- function() {
67
71
# ' documented here.
68
72
# ' @export
69
73
# ' @rdname github_actions
70
- use_github_actions_badge <- function (name = " R-CMD-check" , repo_spec = NULL ) {
74
+ use_github_actions_badge <- function (name = " R-CMD-check.yaml" ,
75
+ repo_spec = NULL ) {
76
+ if (path_ext(name ) == " " ) {
77
+ name <- path_ext_set(name , " yaml" )
78
+ }
71
79
repo_spec <- repo_spec %|| % target_repo_spec()
72
80
enc_name <- utils :: URLencode(name )
73
- img <- glue(" https://github.com/{repo_spec}/workflows/{enc_name}/badge.svg" )
74
- url <- glue(" https://github.com/{repo_spec}/actions" )
81
+ img <- glue(" https://github.com/{repo_spec}/actions/ workflows/{enc_name}/badge.svg" )
82
+ url <- glue(" https://github.com/{repo_spec}/actions/workflows/{enc_name} " )
75
83
76
- use_badge(name , url , img )
84
+ use_badge(path_ext_remove( name ) , url , img )
77
85
}
78
86
79
87
uses_github_actions <- function () {
@@ -113,7 +121,9 @@ use_github_action <- function(name,
113
121
open = FALSE ) {
114
122
if (is.null(url )) {
115
123
check_string(name )
116
- name <- path_ext_set(name , " yaml" )
124
+ if (path_ext(name ) == " " ) {
125
+ name <- path_ext_set(name , " yaml" )
126
+ }
117
127
url <- glue(
118
128
" https://raw.githubusercontent.com/r-lib/actions/v1/examples/{name}"
119
129
)
@@ -158,7 +168,7 @@ use_github_action_check_release <- function(save_as = "R-CMD-check.yaml",
158
168
ignore = ignore ,
159
169
open = open
160
170
)
161
- use_github_actions_badge(" R-CMD-check " )
171
+ use_github_actions_badge(save_as )
162
172
}
163
173
164
174
# ' @section `use_github_action_check_standard()`:
@@ -178,7 +188,7 @@ use_github_action_check_standard <- function(save_as = "R-CMD-check.yaml",
178
188
ignore = ignore ,
179
189
open = open
180
190
)
181
- use_github_actions_badge(" R-CMD-check " )
191
+ use_github_actions_badge(save_as )
182
192
}
183
193
184
194
# ' @section `use_github_action_pr_commands()`:
@@ -229,7 +239,7 @@ use_tidy_github_actions <- function() {
229
239
# it who are better served by something less over-the-top
230
240
# now we inline it here
231
241
full_status <- use_github_action(" check-full.yaml" , save_as = " R-CMD-check.yaml" )
232
- use_github_actions_badge(" R-CMD-check" , repo_spec = repo_spec )
242
+ use_github_actions_badge(" R-CMD-check.yaml " , repo_spec = repo_spec )
233
243
234
244
pr_status <- use_github_action_pr_commands()
235
245
pkgdown_status <- use_github_action(" pkgdown" )
0 commit comments