Restoring a local package for bookdown workflow

Copying from Restoring a local package for bookdown workflow · Issue #443 · r-lib/actions · GitHub

Is it possible to pass RENV_PATHS_LOCAL to the r-lib/actions/examples/bookdown.yml workflow so that I can restore a local package when trying to reproduce the report using github actions?

Otherwise I am hitting this error because my .Renviron with the RENV_PATHS_LOCAL field is not being passed:

Error: Error: failed to retrieve package 'localPackage'

I'm pretty sure I set the env vars globally as well.

Does Workflow commands for GitHub Actions - GitHub Docs help here? If not, can you elaborate a bit more on what your workflow looks like?

I adapted my workflow slightly from usethis::use_github_action("bookdown"):

# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
  push:
    branches: [main, master]

name: bookdown

jobs:
  bookdown:
    runs-on: ubuntu-latest
    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v2

      - uses: r-lib/actions/setup-pandoc@v1

      - uses: r-lib/actions/setup-r@v1
        with:
          use-public-rspm: true

      - name: Install curl
        run: sudo apt-get install libcurl4-openssl-dev

      - uses: r-lib/actions/setup-tinytex@v1

      - uses: r-lib/actions/setup-renv@v1

      - name: Cache bookdown results
        uses: actions/cache@v2
        with:
          path: _bookdown_files
          key: bookdown-${{ hashFiles('**/*Rmd') }}
          restore-keys: bookdown-

      - name: Build site
        run: Rscript -e 'bookdown::render_book("index.Rmd", output_format = "all", quiet = TRUE)'

      - name: Deploy to GitHub pages 🚀
        uses: JamesIves/github-pages-deploy-action@4.1.5
        with:
          branch: gh-pages
          folder: docs

I ran into the error failed to retrieve package 'localPackage'when it got to the r-lib/actions/setup-renv@v1 step because renv does not correctly restore localPackage from RENV_PATHS_LOCAL, set in my local .Renviron. So, my question is whether we are able to pass this environment variable to the workflow. I've tried the following 2 modifications to no avail:

Attempt 1:

jobs:
  bookdown:
    runs-on: ubuntu-latest
    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
      RENV_PATHS_LOCAL: ~/Packages

Attempt 2:

      - name: renv local
        shell: bash
        run: |
          echo "RENV_PATHS_LOCAL=~/Packages" >> $GITHUB_ENV
      - uses: r-lib/actions/setup-renv@v1

Passing the environment using RENV_PATHS_LOCAL as env seems ok.

However, where you package is available for Github action to install it ? The server in which the action will be running needs to have access to the package. ~/Packages means a folder on the server that will build the book.

If your package is only locally install on your computer, the book won't be able to be built on another environment without this package.

So before trying to help you further, how did you make the package available to GHA ? Thanks!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.