32 Case study: a simplified version of the R check-release.yaml
workflow
- Let’s break down a simplified and well annotated version of the R
check-release.yaml
workflow file (full workflow here) to better understand a real use case of GitHub Actions.
on: [push, pull_request]
name: R-CMD-check
jobs:
R-CMD-check:
runs-on: ubuntu-latest
steps:
- name: Checkout files from GitHub version control repository
uses: actions/checkout@v2
- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Install R packages
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check
- name: Checks if R package can be installed
uses: r-lib/actions/check-r-package@v2
Orientating ourselves with the check-release.yaml
workflow
Let’s answer the following questions to start better understanding the check-release.yaml
workflow.
How many jobs are there?
How many steps are there?
What which steps are actions and which are commands
What is the type of runner
What events trigger this workflow?
Adding the check-release.yaml
workflow to your R package repository
There are two ways you can do this. Manually via the GitHub interface:
Go to the actions tab for your GitHub repository
Click on “set up a workflow yourself”
Delete the template action provided to you, and paste the
check-release.yaml
file above into the text editor. Rename the filecheck-release.yaml
.Click “Start commit”, enter a commit message and then click “Commit”.
Or using the usethis::use_github_action
package convenience function:
In the R console run
usethis::use_github_action("check-release")
Put the new
check-release.yaml
file in.github/workflows
under local version control and push the commit to GitHub.