Skip to content

Commit b0a493c

Browse files
Fix "Unknown language engine 'yml'" warnings
* Instead of reading them as code chunks and rendering them via `{yml}`, use inline R expressions as suggested at <https://stackoverflow.com/a/67815701>. * We still read all workflow files upfront to streamline the approach and leverage this for the "ci-cd.yml" workflow included twice. * Consistent usage of `yaml` as plain-markdown fenced block language.
1 parent 61e1b61 commit b0a493c

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

shiny-ci-cd.Rmd

+20-11
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,21 @@ Continuous deployment to shinyapps.io is automated upon any push to the `main` (
8989

9090
### Workflow file
9191

92-
```{r read-ci-cd.yml, eval = TRUE, include = FALSE}
92+
```{r read-workflow-files, eval = TRUE, include = FALSE}
93+
# copy the workflow files so they are included in the rendered book site
9394
file.copy("shiny-ci-cd", "_book", recursive = TRUE)
94-
knitr::read_chunk("shiny-ci-cd/actions/ci-cd.yml", labels = "ci-cd.yml")
95-
knitr::read_chunk("shiny-ci-cd/actions/ci-cd-renv.yml", labels = "ci-cd-renv.yml")
96-
knitr::read_chunk("shiny-ci-cd/actions/ci.yml", labels = "ci.yml")
97-
knitr::read_chunk("shiny-ci-cd/actions/ci-renv.yml", labels = "ci-renv.yml")
95+
# read the workflow files so we can display their content as needed
96+
# (see https://stackoverflow.com/a/67815701)
97+
workflows_content <- sapply(
98+
c("ci-cd.yml", "ci-cd-renv.yml", "ci.yml", "ci-renv.yml"),
99+
function(f) xfun::file_string(file.path("shiny-ci-cd/actions", f))
100+
)
98101
```
99102

100103
The `steps` described in the previous section are defined in the `.yml` workflow file as follows:
101104

102-
```{yml ci-cd.yml}
105+
```yaml
106+
`r workflows_content["ci-cd.yml"]`
103107
```
104108

105109
As visible from the run logs that can be found in the GitHub repository under the `Actions` tab, all the CI/CD pipeline steps are performed subsequently, and are identifiable by the `name` field. See the example below, showing how the deployment step is skipped for a run not triggered by a push action the `main` (or `master`) branch:
@@ -127,25 +131,29 @@ usethis::use_github_actions_badge("ci-cd.yml") # or "ci.yml"/"ci(-cd)-renv.yml"
127131

128132
<details>
129133
<summary><code>shiny-ci-cd/actions/ci-cd.yml</code></summary>
130-
```{yml ci-cd.yml}
134+
```yaml
135+
`r workflows_content["ci-cd.yml"]`
131136
```
132137
</details>
133138

134139
<details>
135140
<summary><code>shiny-ci-cd/actions/ci-cd-renv.yml</code></summary>
136-
```{yml ci-cd-renv.yml}
141+
```yaml
142+
`r workflows_content["ci-cd-renv.yml"]`
137143
```
138144
</details>
139145

140146
<details>
141147
<summary><code>shiny-ci-cd/actions/ci.yml</code></summary>
142-
```{yml ci.yml}
148+
```yaml
149+
`r workflows_content["ci.yml"]`
143150
```
144151
</details>
145152

146153
<details>
147154
<summary><code>shiny-ci-cd/actions/ci-renv.yml</code></summary>
148-
```{yml ci-renv.yml}
155+
```yaml
156+
`r workflows_content["ci-renv.yml"]`
149157
```
150158
</details>
151159

@@ -219,7 +227,8 @@ It is in fact more convenient to write an R script, saved as e.g. `deploy/deploy
219227
```
220228

221229
and then simply execute it as `deploy` `script`:
222-
```yml
230+
231+
```yaml
223232
deploy:
224233
provider: script
225234
skip_cleanup: true # strictly necessary only for the renv case

0 commit comments

Comments
 (0)