Skip to content

Commit aa510ec

Browse files
committed
Update the URLs in use_github_actions_badge()
Closes #1525
1 parent eec44c8 commit aa510ec

File tree

6 files changed

+39
-26
lines changed

6 files changed

+39
-26
lines changed

β€ŽNEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# usethis (development version)
22

3+
`use_github_actions_badge()` now uses the same URLs as GitHub does via the "Create status badge" helper in the browser (#1525). This changes the signicance of the `name` argument; now it really must be the name of the workflow configuration file.
4+
35
# usethis 2.1.5
46

57
pkgdown-related functions no longer automatically strip a trailing slash from the pkgdown site URL, in order to play more nicely with CRAN's URL checks (#1526).

β€ŽR/badge.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use_badge <- function(badge_name, href, src) {
5656
)
5757

5858
if (changed && path_ext(path) == "Rmd") {
59-
ui_todo("Re-knit {ui_path(path)}")
59+
ui_todo("Re-knit {ui_path(path)} with {ui_code('devtools::build_readme()')}")
6060
}
6161
invisible(changed)
6262
}

β€ŽR/github-actions.R

+23-13
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
#' * Provides the markdown to insert a badge into your README
2020
#'
2121
#' @name github_actions
22+
2223
#' @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".
2529
#'
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`.
2931
#' @eval param_repo_spec()
3032
#' @param url The full URL to a `.yaml` file on GitHub.
3133
#' @param save_as Name of the local workflow file. Defaults to `name` or
@@ -36,10 +38,12 @@
3638
#' about the workflow. Ignored when `url` is `NULL`.
3739
#' @inheritParams use_template
3840
#'
41+
3942
#' @seealso
4043
#' * [use_github_file()] for more about `url` format and parsing.
4144
#' * [use_tidy_github_actions()] for the standard GitHub Actions used for
4245
#' tidyverse packages.
46+
4347
#' @examples
4448
#' \dontrun{
4549
#' use_github_actions()
@@ -67,13 +71,17 @@ use_github_actions <- function() {
6771
#' documented here.
6872
#' @export
6973
#' @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+
}
7179
repo_spec <- repo_spec %||% target_repo_spec()
7280
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}")
7583

76-
use_badge(name, url, img)
84+
use_badge(path_ext_remove(name), url, img)
7785
}
7886

7987
uses_github_actions <- function() {
@@ -113,7 +121,9 @@ use_github_action <- function(name,
113121
open = FALSE) {
114122
if (is.null(url)) {
115123
check_string(name)
116-
name <- path_ext_set(name, "yaml")
124+
if (path_ext(name) == "") {
125+
name <- path_ext_set(name, "yaml")
126+
}
117127
url <- glue(
118128
"https://raw.githubusercontent.com/r-lib/actions/v1/examples/{name}"
119129
)
@@ -158,7 +168,7 @@ use_github_action_check_release <- function(save_as = "R-CMD-check.yaml",
158168
ignore = ignore,
159169
open = open
160170
)
161-
use_github_actions_badge("R-CMD-check")
171+
use_github_actions_badge(save_as)
162172
}
163173

164174
#' @section `use_github_action_check_standard()`:
@@ -178,7 +188,7 @@ use_github_action_check_standard <- function(save_as = "R-CMD-check.yaml",
178188
ignore = ignore,
179189
open = open
180190
)
181-
use_github_actions_badge("R-CMD-check")
191+
use_github_actions_badge(save_as)
182192
}
183193

184194
#' @section `use_github_action_pr_commands()`:
@@ -229,7 +239,7 @@ use_tidy_github_actions <- function() {
229239
# it who are better served by something less over-the-top
230240
# now we inline it here
231241
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)
233243

234244
pr_status <- use_github_action_pr_commands()
235245
pkgdown_status <- use_github_action("pkgdown")

β€ŽREADME.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ knitr::opts_chunk$set(
1616
# usethis <img src="man/figures/logo.png" align="right" height="139" />
1717

1818
<!-- badges: start -->
19-
[![R-CMD-check](https://github.com/r-lib/usethis/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/usethis/actions)
19+
[![R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml)
2020
[![Codecov test coverage](https://codecov.io/gh/r-lib/usethis/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/usethis?branch=main)
2121
[![CRAN status](https://www.r-pkg.org/badges/version/usethis)](https://CRAN.R-project.org/package=usethis)
2222
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)

β€ŽREADME.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<!-- badges: start -->
77

8-
[![R-CMD-check](https://github.com/r-lib/usethis/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/usethis/actions)
8+
[![R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml)
99
[![Codecov test
1010
coverage](https://codecov.io/gh/r-lib/usethis/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/usethis?branch=main)
1111
[![CRAN
@@ -60,8 +60,8 @@ library(usethis)
6060
# Create a new package -------------------------------------------------
6161
path <- file.path(tempdir(), "mypkg")
6262
create_package(path)
63-
#> βœ“ Creating '/tmp/Rtmp86lEpD/mypkg/'
64-
#> βœ“ Setting active project to '/private/tmp/Rtmp86lEpD/mypkg'
63+
#> βœ“ Creating '/tmp/RtmpCnD2JV/mypkg/'
64+
#> βœ“ Setting active project to '/private/tmp/RtmpCnD2JV/mypkg'
6565
#> βœ“ Creating 'R/'
6666
#> βœ“ Writing 'DESCRIPTION'
6767
#> Package: mypkg
@@ -79,8 +79,8 @@ create_package(path)
7979
#> βœ“ Setting active project to '<no active project>'
8080
# only needed since this session isn't interactive
8181
proj_activate(path)
82-
#> βœ“ Setting active project to '/private/tmp/Rtmp86lEpD/mypkg'
83-
#> βœ“ Changing working directory to '/tmp/Rtmp86lEpD/mypkg/'
82+
#> βœ“ Setting active project to '/private/tmp/RtmpCnD2JV/mypkg'
83+
#> βœ“ Changing working directory to '/tmp/RtmpCnD2JV/mypkg/'
8484

8585
# Modify the description ----------------------------------------------
8686
use_mit_license("My Name")

β€Žman/github_actions.Rd

+7-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
Β (0)