Github Actions with R

R

Deploy and automate your code to the cloud

shikokuchuo
05-04-2021

                                                            sha256
1 6f5b37d9b73dcd70f3c8b68eabbe00c4a709f2a3e694d964121af145105f1655

Github Actions with R

Set up a cron job to run your R scripts at specified times.

Enabled with a simple yaml configuration file.

Save the following as main.yml in .github/workflows of your Github repository:

name: Action
on:
  schedule:
    - cron: '30 22 * * 1-5'
jobs:
  render:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      - name: Set up R
        uses: r-lib/actions/setup-r@v1
      - name: Install dependencies
        run: |
          install.packages(c("magrittr", "purrr"), type = "win.binary")
        shell: Rscript {0}
      - name: Script
        run: Rscript nameofscript.R
      - name: Commit files
        run: |
          git config --local user.name github-actions
          git config --local user.email "actions@github.com"
          git add docs/*
          git commit -am "commit on $(date)"
          git push origin main
        env:
          REPO_KEY: ${{secrets.GITHUB_TOKEN}}
          username: github-actions

To generate R Markdown documents (or for that matter render a Distill website), you will want to add the following step after ‘Set up R’:

      - name: Set up Pandoc
        uses: r-lib/actions/setup-pandoc@v1

Reference

The Github Actions with R reference:
https://orchid00.github.io/actions_sandbox/

Citation

For attribution, please cite this work as

shikokuchuo (2021, May 4). shikokuchuo{net}: Github Actions with R. Retrieved from https://shikokuchuo.net/posts/05-ghactions/

BibTeX citation

@misc{shikokuchuo2021github,
  author = {shikokuchuo, },
  title = {shikokuchuo{net}: Github Actions with R},
  url = {https://shikokuchuo.net/posts/05-ghactions/},
  year = {2021}
}