forked from Open-Systems-Pharmacology/TLF-Library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yuri05
authored and
Yuri05
committed
Feb 19, 2024
1 parent
19502ff
commit 6b2ce43
Showing
2 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Create GitHub pages for an R package | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
pkgdown_mode: | ||
required: true | ||
type: string | ||
enum: ['devel', 'release'] | ||
extra_r_packages: | ||
required: false | ||
type: string | ||
gh-pages-branch: | ||
required: false | ||
type: string | ||
default: 'gh-pages' | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
PKGDOWN_MODE: ${{ inputs.pkgdown_mode }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup | ||
uses: r-lib/actions/setup-r@v2 | ||
with: | ||
use-public-rspm: true | ||
- name: Setup Pandoc | ||
uses: r-lib/actions/setup-pandoc@v2 | ||
- name: Install required packages | ||
uses: r-lib/actions/setup-r-dependencies@v2 | ||
with: | ||
extra-packages: | | ||
${{ inputs.extra_r_packages }} | ||
any::pkgdown | ||
local::. | ||
needs: website | ||
- name: Remove build number from the DESCRIPTION and build site | ||
run: | | ||
description <- readLines('DESCRIPTION') | ||
versionLine <- grep(pattern = 'Version: [0-9]\\.[0-9]\\.[0-9]', description) | ||
description[versionLine] <- gsub(pattern = '\\.[0-9]$', replacement = '', description[versionLine]) | ||
writeLines(description, 'DESCRIPTION') | ||
options(yaml.eval.expr=TRUE) | ||
pkgdown::build_site(devel=TRUE, install=TRUE) | ||
shell: Rscript {0} | ||
# The project is then uploaded as an artifact named 'docs'. | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v1 | ||
with: | ||
name: docs | ||
path: docs | ||
|
||
deploy: | ||
concurrency: ci-${{ github.ref }} | ||
# The second job must depend on the first one to complete before running and uses ubuntu-latest instead of windows. | ||
needs: [build] | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
# The built project is downloaded into the 'docs' folder. | ||
- name: Download Artifacts | ||
uses: actions/download-artifact@v1 | ||
with: | ||
name: docs | ||
- name: Deploy | ||
uses: JamesIves/github-pages-deploy-action@v4 | ||
# The deployment folder should match the name of the artifact. | ||
# Clean is false to prevent removing release site | ||
# only target folder of repo from gh-pages branch is updated | ||
with: | ||
folder: docs | ||
clean: false | ||
branch: ${{ inputs.gh-pages-branch }} | ||
target-folder: docs | ||
token: ${{ secrets.GITHUB_TOKEN }} |
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