Bootstrap or Restore renv #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/renv-bootstrap-or-restore.yml | |
| name: Bootstrap or Restore renv | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 6 * * 1" # Mondays 06:00 UTC | |
| jobs: | |
| renv: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: { fetch-depth: 0 } | |
| - uses: r-lib/actions/setup-r@v2 | |
| with: | |
| r-version: "release" | |
| - name: Install renv | |
| run: Rscript -e 'install.packages("renv", repos="https://cloud.r-project.org")' | |
| - name: Bootstrap or restore | |
| id: renv | |
| run: | | |
| Rscript - <<'RSCRIPT' | |
| if (!file.exists("renv.lock")) { | |
| message("No renv.lock found — bootstrapping…") | |
| renv::init(bare = TRUE) | |
| # Optionally install dev deps here, e.g.: | |
| # renv::install(c("devtools","roxygen2","testthat")) | |
| renv::snapshot(prompt = FALSE) | |
| cat("BOOTSTRAPPED=1\n", file = Sys.getenv("GITHUB_OUTPUT"), append = TRUE) | |
| } else { | |
| message("renv.lock found — restoring…") | |
| renv::restore(prompt = FALSE) | |
| cat("BOOTSTRAPPED=0\n", file = Sys.getenv("GITHUB_OUTPUT"), append = TRUE) | |
| } | |
| RSCRIPT | |
| - name: Create PR with initial lockfile | |
| if: steps.renv.outputs.BOOTSTRAPPED == '1' | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| commit-message: "chore(renv): initialize renv and add lockfile" | |
| title: "chore(renv): bootstrap renv" | |
| body: "Initial `renv` setup: adds `.Rprofile`, `renv/activate.R`, and `renv.lock`." | |
| branch: "chore/renv-bootstrap" | |
| labels: dependencies,R | |
| reviewers: diogoribeiro7 | |