bcgov / bcgovr

An R package to automate set up and sharing of R projects in bcgov GitHub following bcgov guidelines
Apache License 2.0
34 stars 5 forks source link

Add unbranded pkgdown site for easier access to documentation #75

Open stephhazlitt opened 2 months ago

stephhazlitt commented 2 months ago

Follow same design as bcdata and bcmaps.

jonjunduan commented 1 month ago

Still only able to create a static site using "pkgdown::build_site()" and all the static site files are inside the "docs" folder. And then in repo "setting"

  1. Click on the "Settings" tab near the top of the page.
  2. In the left sidebar, scroll down and click on "Pages" under the "Code and automation" section.
  3. In the "Build and deployment" section, you'll see a "Source" dropdown menu.
  4. Click on the dropdown and select "Deploy from a branch".
  5. In the "Branch" section, select "this_branch" from the branch dropdown menu.
  6. For the folder, select "/docs" unless you have a specific folder you want to use.
  7. Click the "Save" button.

I had tried the regular method:

  1. Create a new file in your package repository at .github/workflows/pkgdown.yaml. a. use the basic setting which is the same as https://github.com/bcgov/bcdata/blob/main/.github/workflows/pkgdown.yaml. b. it fails in this step:
      - uses: r-lib/actions/setup-r-dependencies@v2
        with:
          extra-packages: any::pkgdown, local::.
          needs: website

The errors are that it fails to build bcgovr package:

ℹ Packaging bcgovr 1.0.5.9999
  ✔ Packaged bcgovr 1.0.5.9999 (1.1s)
  ℹ Building bcgovr 1.0.5.9999
  ✖ Failed to build bcgovr 1.0.5.9999 (1.3s)
  Error: 
  ! error in pak subprocess
  Caused by error in `stop_task_build(state, worker)`:
  ! Failed to build source package bcgovr.
  Full installation output:
  * installing *source* package ‘bcgovr’ ...
  staged installation is only possible with locking
  ** using non-staged installation
  ** R
  ** inst
  ** byte-compile and prepare package for lazy loading
  • GitHub host: "https://github.com/"
  • Personal access token for "https://github.com/": <discovered>
  ✖ Can't get user information for this token.
  ℹ GitHub API error (403): Resource not accessible by integration
  ☐ Call `gitcreds::gitcreds_set()` to register this token in the local Git
    credential store.
  ! On Linux, it can be tricky to store credentials persistently.
  ℹ Read more in the 'Managing Git(Hub) Credentials' article
    (<https://usethis.r-lib.org/articles/articles/git-credentials.html>).
  ℹ It is also a great idea to store this token in any password-management
    software that you use.
  ☐ Open URL
    <https://github.com/settings/tokens/new?scopes=repo,user,gist,workflow&description=DESCRIBE
    THE TOKEN'S USE CASE>.
  Error in throw(new_error("gitcreds_not_interactive_error", message = "`gitcreds_set()` only works in interactive sessions")) : 
    `gitcreds_set()` only works in interactive sessions
  Error: Error: unable to load R code in package ‘bcgovr’
  Execution halted
  ERROR: lazy loading failed for package ‘bcgovr’
  * removing ‘/tmp/RtmpKZ37aP/pkg-lib12af7c7ef7bc/bcgovr’
  ---
  Backtrace:
  1. pak::lockfile_install(".github/pkg.lock")
  2. pak:::remote(function(...) { …
  3. err$throw(res$error)
  ---
  Subprocess backtrace:
   1. base::withCallingHandlers(cli_message = function(msg) { …
   2. get("lockfile_install_internal", asNamespace("pak"))(...)
   3. plan$install()
   4. pkgdepends::install_package_plan(plan, lib = private$library, num_workers = nw, …
   5. base::withCallingHandlers({ …
   6. pkgdepends:::handle_events(state, events)
   7. pkgdepends:::handle_event(state, i)
   8. pkgdepends:::stop_task(state, worker)
   9. pkgdepends:::stop_task_build(state, worker)
  10. base::throw(pkg_error("Failed to build source package {.pkg {pkg}}.", …
  11. | base::signalCondition(cond)
  12. global (function (e) …
  Execution halted
  Error: Process completed with exit code 1.

This step is necessary since the next step: "Build site" will need the package "bcgovr" to create the documents.

If we can solve this problem, we can make it work.