build_ghworkflow: Build GitHub Action Workflow

View source: R/memoiR.R

build_ghworkflowR Documentation

Build GitHub Action Workflow

Description

Build a YAML file (.gihub/workflows/memoir.yml) to knit the documents of the project to GitHub Pages. The workflow knits all R Markdown files according their header: all output formats are produced and stored into the gh-pages branch of the project.

Usage

build_ghworkflow()

Details

All HTML outputs have the same name so the last one knitted overwrites the previous ones. Keep only one HTML format in the header of each RMarkdown file.

No DESCRIPTION file is necessary in the project to install packages. They must be declared in the options code chunk of each .Rmd file (index.Rmd for the memoir template).

Two secrets must have been stored in the GitHub account:

  • GH_PAT: a valid access token,

  • EMAIL: the email address to send the workflow results to.

Value

The content of the YAML file as a vector of characters, invisibly. Each element is a line of the file.

Examples

## Simulate the creation of a new project
# Save working directory
original_wd <- getwd()
# Get a temporary working directory
wd <- tempfile("example")
# Simulate File > New File > R Markdown... > From Template > Simple Article
rmarkdown::draft(wd, template="simple_article", package="memoiR", edit=FALSE)
# Go to temp directory
setwd(wd)
# Make it the current project
usethis::proj_set(path = ".", force = TRUE)

# Build GitHub Actions Workflow script
build_ghworkflow()
# Content
readLines(".github/workflows/memoir.yml")

## End of the example: cleanup
# Return to the original working directory and clean up
setwd(original_wd)
unlink(wd, recursive=TRUE)


memoiR documentation built on Sept. 14, 2023, 5:06 p.m.