Skip to content

Commit 1cae15a

Browse files
authored
[DOC] Publish HTML documentation preview on surge (#128)
When documentation source files change, publish the generated documentation to surge to easy the review. Create a workflow that will later include a job to publish to `gh-pages`. The HTML documentation content is not customized nor updated. This will be done later.
1 parent 371cc1e commit 1cae15a

File tree

6 files changed

+118
-12
lines changed

6 files changed

+118
-12
lines changed

.Rbuildignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@
66
^.*\.md$
77
^doc$
88
^LICENSE$
9+
^_pkgdown\.yml$
10+
^docs$
11+
^pkgdown$
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: 'Build Setup'
2+
description: 'Setup R and install dependencies'
3+
inputs:
4+
dependencies-extra-packages:
5+
description: '`extra-packages` input for the `setup-r-dependencies` action.'
6+
required: true
7+
dependencies-needs:
8+
description: '`needs` input for the `setup-r-dependencies` action.'
9+
required: true
10+
r-version:
11+
description: 'The R version to use.'
12+
required: true
13+
runs:
14+
using: 'composite'
15+
steps:
16+
- uses: r-lib/actions/setup-r@v2
17+
with:
18+
r-version: ${{ inputs.r-version }}
19+
use-public-rspm: true
20+
- uses: r-lib/actions/setup-r-dependencies@v2
21+
with:
22+
extra-packages: ${{ inputs.dependencies-extra-packages }}
23+
needs: ${{ inputs.dependencies-needs }}
24+
# to generate documentation
25+
- uses: r-lib/actions/setup-pandoc@v2
26+
# Sets up LaTeX with tinytex, for PDF generation
27+
- uses: r-lib/actions/setup-tinytex@v2
28+
29+

.github/workflows/R-CMD-check.yaml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
tags:
99
- v*
1010
paths:
11+
- '.github/actions/build-setup/**/*'
1112
- '.github/workflows/R-CMD-check.yaml'
1213
- 'R/**/*'
1314
- 'inst/**/*'
@@ -19,6 +20,7 @@ on:
1920
branches:
2021
- main
2122
paths:
23+
- '.github/actions/build-setup/**/*'
2224
- '.github/workflows/R-CMD-check.yaml'
2325
- 'R/**/*'
2426
- 'inst/**/*'
@@ -49,14 +51,11 @@ jobs:
4951

5052
steps:
5153
- uses: actions/checkout@v3
52-
- uses: r-lib/actions/setup-r@v2
54+
- uses: ./.github/actions/build-setup
5355
with:
56+
dependencies-extra-packages: any::rcmdcheck
57+
dependencies-needs: check
5458
r-version: ${{ matrix.config.r }}
55-
- uses: r-lib/actions/setup-r-dependencies@v2
56-
with:
57-
extra-packages: any::rcmdcheck
58-
needs: check
59-
- uses: r-lib/actions/setup-pandoc@v2
6059
- uses: r-lib/actions/check-r-package@v2
6160

6261

@@ -74,12 +73,6 @@ jobs:
7473
with:
7574
name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-source-package
7675
path: bpmnVisualization_*.tar.gz
77-
78-
79-
# Sets up LaTeX with tinytex, for PDF generation
80-
# not needed before as the checks on the repo sources are done with --no-manual
81-
- uses: r-lib/actions/setup-tinytex@v2
82-
8376
- name: Check the source package
8477
id: source_package_checks
8578
run: R CMD check --as-cran bpmnVisualization_*.tar.gz
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish Documentation
2+
3+
on:
4+
pull_request:
5+
# To manage 'surge-preview' action teardown, add default event types + closed event type
6+
types: [opened, synchronize, reopened, closed]
7+
branches:
8+
- main
9+
paths:
10+
- '.github/actions/build-setup/**/*'
11+
- '.github/workflows/publish-documentation.yml'
12+
- 'inst/**'
13+
- 'man/**'
14+
- '.Rbuildignore'
15+
- '_pkgdown.yml'
16+
- 'CONTRIBUTING.md'
17+
- 'DESCRIPTION'
18+
- 'README.md' # TODO use the right file, the repo from the repo cannot be included (wrong format, too much info)
19+
20+
jobs:
21+
# for Pull Request
22+
pr_preview: # the id is used by surge to generate the surge url
23+
if: github.event_name == 'pull_request'
24+
runs-on: ubuntu-22.04
25+
permissions:
26+
pull-requests: write # surge-preview: PR comments
27+
steps:
28+
- uses: actions/checkout@v3
29+
if: github.event.action != 'closed'
30+
- uses: ./.github/actions/build-setup
31+
if: github.event.action != 'closed'
32+
with:
33+
dependencies-extra-packages: any::pkgdown, local::.
34+
dependencies-needs: website
35+
r-version: release
36+
- name: Build documentation website
37+
if: github.event.action != 'closed'
38+
shell: Rscript {0}
39+
run: |
40+
pkgdown::build_site()
41+
# Always upload the website for local browsing and when it cannot be deployed to surge
42+
- name: Upload documentation
43+
if: github.event.action != 'closed'
44+
uses: actions/upload-artifact@v3
45+
with:
46+
name: documentation-${{github.sha}}
47+
path: docs
48+
- uses: bonitasoft/actions/packages/surge-preview-tools@v2
49+
id: surge-preview-tools
50+
with:
51+
surge-token: ${{ secrets.SURGE_TOKEN }}
52+
- name: Manage surge preview
53+
if: steps.surge-preview-tools.outputs.can-run-surge-command == 'true'
54+
id: doc_preview
55+
uses: afc163/surge-preview@v1
56+
with:
57+
surge_token: ${{ secrets.SURGE_TOKEN }}
58+
github_token: ${{ secrets.GITHUB_TOKEN }}
59+
dist: docs
60+
failOnError: true
61+
teardown: true
62+
build: ls -lh docs

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,6 @@ vignettes/*.pdf
4444

4545
# R Environment Variables
4646
.Renviron
47+
48+
# Generated documentation
49+
docs

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ To regenerate this documentation after function comment updating, run this comma
113113
devtools::document()
114114
```
115115

116+
### Generate the HTML documentation (site)
117+
118+
The HTML documentation is generated with [pkgdown](https://pkgdown.r-lib.org).
119+
120+
If you need to test locally changes in the configuration or content of this documentation, install `pkgdown` following the [official documentation](https://pkgdown.r-lib.org/#installation).
121+
122+
**Note**: on Ubuntu, you may encounter errors during the installation of `pkgdown`. In particular, the installation of some dependent packages may fail:
123+
- `systemfonts`: run `sudo apt -y install libfontconfig1-dev` (see [systemfonts#35](https://github.com/r-lib/systemfonts/issues/35#issuecomment-633560151) )
124+
- `textshapping`: `run sudo apt -y install libharfbuzz-dev libfribidi-dev`
125+
126+
Once `pkgdown` is installed, you can generate the HTML documentation quickly with this command:
127+
```
128+
pkgdown::build_site(devel = TRUE, lazy = TRUE, preview = FALSE)
129+
```
130+
For more details about the available options, see [the official documentation](https://pkgdown.r-lib.org/reference/build_site.html).
131+
116132
### bpmn-visualization TypeScript library update
117133

118134
The [bpmn-visualization](https://github.com/process-analytics/bpmn-visualization-js) dependency is automatically updated by the [Update bpmn-visualization version](.github/workflows/update_bpmn_visualization_version.yml) workflow when a new version of this library is released.

0 commit comments

Comments
 (0)