Repository navigation
132 lines (113 loc) · 3.82 KB
/
Copy pathpkgdown.yaml
File metadata and controls
132 lines (113 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
# build dev site on merged pushes
push:
branches: [main, master]
pull_request:
types: [opened, reopened, synchronize, labeled, closed]
# build full site on releases
release:
types: [published]
workflow_dispatch:
name: pkgdown.yaml
jobs:
pkgdown:
# For PRs, only run when the PR has the build-website label.
if: >-
github.event_name != 'pull_request' ||
(
github.event.action != 'closed' &&
contains(github.event.pull_request.labels.*.name, 'build-website') &&
(github.event.action != 'labeled' || github.event.label.name == 'build-website')
)
runs-on: ubuntu-latest
concurrency:
group: pkgdown-${{ github.event_name == 'pull_request' && github.event.pull_request.number || 'production' }}
cancel-in-progress: true
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
NOT_CRAN: "true"
permissions:
contents: write
steps:
- uses: actions/checkout@v7
- uses: r-lib/actions/setup-pandoc@v2
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::., stan-dev/pkgdown-config
- name: Build site
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
override <- list()
pr_number <- Sys.getenv("PR_NUMBER")
if (nzchar(pr_number)) {
pkg <- pkgdown::as_pkgdown(".")
if (pkg$development$mode == "devel") {
Sys.setenv(PKGDOWN_DEV_MODE = "unreleased")
}
override <- list(
url = paste0(pkg$meta$url, "/pr/", pr_number),
template = list(
params = list(noindex = TRUE)
)
)
}
pkgdown::build_site_github_pages(
lazy = FALSE,
run_dont_run = TRUE,
new_process = TRUE,
override = override
)
shell: Rscript {0}
- name: Deploy PR preview
# Forks cannot deploy the site
if: >
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs
target-folder: pr/${{ github.event.pull_request.number }}
clean: true
force: false
- name: Deploy site
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: docs
clean: false
force: false
cleanup-preview:
if: >-
github.event_name == 'pull_request' && github.event.action == 'closed'
&& github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
concurrency:
group: pkgdown-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: write
steps:
- uses: actions/checkout@v7
with:
ref: gh-pages
- name: Remove PR preview
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git rm -r --ignore-unmatch "pr/$PR_NUMBER"
if git diff --cached --quiet; then
exit 0
fi
git commit -m "Remove pkgdown preview for PR #$PR_NUMBER"
git pull --rebase origin gh-pages
git push origin HEAD:gh-pages