Skip to content

Instantly share code, notes, and snippets.

@lucyb
Created October 30, 2022 20:26
Show Gist options
  • Save lucyb/61e44498d124c11ef91bedd082e5c6c8 to your computer and use it in GitHub Desktop.
Save lucyb/61e44498d124c11ef91bedd082e5c6c8 to your computer and use it in GitHub Desktop.
Run an R script once a day
on:
schedule:
# Run every day at 19:00
- cron: "0 19 * * *"
jobs:
generate-data:
runs-on: ubuntu-latest
env:
# Put any environment variables the script needs here
# See https://github.com/Azure/actions-workflow-samples/blob/master/assets/create-secrets-for-GitHub-workflows.md
TWITTER_API_KEY: ${{ secrets.TWITTER_API_KEY }}
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@master
with:
r-version: release
- name: Query dependencies
run: |
install.packages('remotes')
install.packages('sessioninfo')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
- name: Cache R packages
uses: actions/cache@v1
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
shell: Rscript {0}
- name: Generate graph
run: |
source("R/script.R")
shell: Rscript {0}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment