Last active
September 25, 2020 15:12
-
-
Save cimentadaj/baa138ae62db002425268cafd057ac84 to your computer and use it in GitHub Desktop.
This file contains 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
## DO NOT DELETE ME. I am linked to an automatic weekly process that sources me. | |
## If you UPDATE ME, remember to change me at the `pkgdown` Github actions workflow file for the R package `tidyflow` | |
# This function does pretty much the same thing as the equivalent pkgdown function. | |
# But on top of it, it copies all PDF files from the presentations from inside `vignettes` | |
# to the articles folder inside the website, to allow to cross-reference pdf files | |
# inside the website. | |
# However, to avoid more internal dependencies of `pkgdown`, I removed the part that creates the gh-pages branch | |
# fom the code. If you delete gh-pages, this function won't create it. | |
deploy_to_branch2 <- function (pkg = ".", | |
commit_message = pkgdown:::construct_commit_message(pkg), | |
branch = "gh-pages", | |
remote = "origin", | |
github_pages = (branch == "gh-pages"), | |
...) { | |
orig_dir <- pkg | |
dest_dir <- tempfile() | |
dir.create(dest_dir, recursive = TRUE) | |
on.exit(unlink(dest_dir, recursive = TRUE)) | |
pkgdown:::git("remote", "set-branches", remote, branch) | |
pkgdown:::git("fetch", remote, branch) | |
pkgdown:::github_worktree_add(dest_dir, remote, branch) | |
on.exit(pkgdown:::github_worktree_remove(dest_dir), add = TRUE) | |
pkg <- pkgdown::as_pkgdown(pkg, override = list(destination = dest_dir)) | |
pkgdown::build_site(pkg, devel = FALSE, preview = FALSE, install = FALSE) | |
if (github_pages) { | |
pkgdown:::build_github_pages(pkg) | |
} | |
presentation_path <- | |
file.path( | |
normalizePath(orig_dir), | |
"vignettes/presentations" | |
) | |
all_presentations <- | |
list.files( | |
presentation_path, | |
recursive = TRUE, | |
pattern = ".pdf$", | |
full.names = TRUE | |
) | |
file.copy(all_presentations, file.path(dest_dir, "articles")) | |
pkgdown:::github_push(dest_dir, commit_message, remote, branch) | |
invisible() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment