Running code while we’re sleeping

Introduction to GitHub Actions for R users
R-Ladies Abuja, Nigeria

Beatriz Milz

Beatriz Milz 🇧🇷

  • Contact

  • About Bea

    • R-Ladies São Paulo Co-organizer

    • Teacher at Curso-R

    • Tidyverse instructor certified by RStudio

What powers GitHub Actions give us?

  • Running code while we’re sleeping!

Run arbitrary R scripts

  • Scrape data from the internet

  • Run reports with RMarkdown or Quarto

  • Send emails

  • Save results

  • Deploy Shiny Apps.

  • .. And so on! Depends on what are your skills in R.

Package development

  • Run devtools::check()

  • Run tests

  • Build and update documentation and website

Git and GitHub

Git

  • Git is a Version Control System (VCS).

  • It is able to store the change history of all files inside a folder, which we call a repository.

  • It becomes important as your work is collaborative.

  • Git is software that you can install on your computer.

GitHub

  • GitHub is a service where you store and share Git repositories.

  • Used by millions of people in open or closed source projects.

  • Useful for collaborating with other programmers on data science projects.

  • There are alternatives such as GitLab and BitBucket.

  • GitHub is a website that you can access on the internet.

Using Git and GitHub in RStudio

GitHub Actions

What is GitHub Actions?

  • It is a service from GitHub

  • Allows us to automate code executions in the cloud.

Concepts

  • GitHub Actions allows us to create workflows.

  • GH workflows are linked to repositories.

  • A workflow needs a description of Events and Jobs.

  • Events: describes what triggers the workflow: in what conditions should the workflow run?

  • Jobs: what the workflow should do? Imagine that its a brand new computer with no R installed, and we have to do all the setup in this step!

  • Documentation: https://docs.github.com/en/actions

Important!

  • Workflows are stored in .yaml files.

  • The .yaml files must be in a specific directory: .github/workflows/workflow-name.yaml

Tips

  • In the repository r-lib/actions there are some examples of GitHub Actions workflows that we can use and adapt.

  • Package {usethis} is helpful to use some GHA workflows available in r-lib/actions: usethis::use_github_action() function.

  • Start from an existing workflow file, and change what is necessary.

Let’s practice it!

More content..

Presentation at rstudio::conf(2022) :

https://beamilz.com/talks/en/2022-rstudio-conf/

More examples…

https://beamilz.com/series-gha.html

References

English

In Portuguese

Thanks!