Skip to content

Commit bc2c22f

Browse files
authored
ci: same pr-commands as other epi packages (#325)
* ci: same pr-commands as other epi packages * document, style now PR commands * docs preview is now available * ci: be a bit more judicious when triggering ci
1 parent d5c51e1 commit bc2c22f

File tree

7 files changed

+180
-135
lines changed

7 files changed

+180
-135
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ on:
55
branches: [main, dev]
66
pull_request:
77
branches: [main, dev]
8+
paths:
9+
- '**.R'
10+
- '**.Rmd'
11+
- DESCRIPTION
12+
- NAMESPACE
13+
- man/**
14+
- R/**
15+
- tests/**
816
workflow_dispatch:
917

1018
name: R-CMD-check

.github/workflows/document.yaml

Lines changed: 0 additions & 52 deletions
This file was deleted.

.github/workflows/lint.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ on:
55
branches: [main, dev]
66
pull_request:
77
branches: [main, dev]
8+
paths:
9+
- '**.R'
10+
- '**.Rmd'
11+
- DESCRIPTION
12+
- NAMESPACE
13+
- man/**
14+
- R/**
815
workflow_dispatch:
916

1017
name: lint

.github/workflows/pkgdown.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ on:
88
branches: [main, dev]
99
pull_request:
1010
branches: [main, dev]
11+
paths:
12+
- '**.R'
13+
- '**.Rmd'
14+
- DESCRIPTION
15+
- NAMESPACE
16+
- man/**
17+
- R/**
18+
- _pkgdown.yml
1119
release:
1220
types: [published]
1321
workflow_dispatch:

.github/workflows/pr-commands.yaml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
# Modifications:
4+
# - Allow more roles to trigger each PR command
5+
# - Document builds README.md from README.Rmd with devtools::build_readme()
6+
# - Include a doc-preview command (uses Netlify to preview the docs)
7+
on:
8+
issue_comment:
9+
types: [created]
10+
11+
name: pr-commands.yaml
12+
13+
permissions: read-all
14+
15+
jobs:
16+
document:
17+
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
18+
name: document
19+
runs-on: ubuntu-latest
20+
env:
21+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
22+
permissions:
23+
contents: write
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- uses: r-lib/actions/pr-fetch@v2
28+
with:
29+
repo-token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- uses: r-lib/actions/setup-r@v2
32+
with:
33+
use-public-rspm: true
34+
35+
- uses: r-lib/actions/setup-r-dependencies@v2
36+
with:
37+
extra-packages: any::roxygen2
38+
needs: pr-document
39+
40+
- name: Document
41+
run: roxygen2::roxygenise()
42+
shell: Rscript {0}
43+
44+
- name: Build README.md from README.Rmd
45+
run: Rscript -e 'if (file.exists("README.Rmd")) devtools::build_readme()'
46+
47+
- name: commit
48+
run: |
49+
git config --local user.name "$GITHUB_ACTOR"
50+
git config --local user.email "[email protected]"
51+
git add man/\* NAMESPACE
52+
git commit -m 'Document'
53+
54+
- uses: r-lib/actions/pr-push@v2
55+
with:
56+
repo-token: ${{ secrets.GITHUB_TOKEN }}
57+
58+
style:
59+
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }}
60+
name: style
61+
runs-on: ubuntu-latest
62+
env:
63+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
64+
permissions:
65+
contents: write
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- uses: r-lib/actions/pr-fetch@v2
70+
with:
71+
repo-token: ${{ secrets.GITHUB_TOKEN }}
72+
73+
- uses: r-lib/actions/setup-r@v2
74+
75+
- name: Install dependencies
76+
run: install.packages("styler")
77+
shell: Rscript {0}
78+
79+
- name: Style
80+
run: styler::style_pkg()
81+
shell: Rscript {0}
82+
83+
- name: commit
84+
run: |
85+
git config --local user.name "$GITHUB_ACTOR"
86+
git config --local user.email "[email protected]"
87+
git add \*.R
88+
git commit -m 'Style'
89+
90+
- uses: r-lib/actions/pr-push@v2
91+
with:
92+
repo-token: ${{ secrets.GITHUB_TOKEN }}
93+
94+
preview:
95+
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'CONTRIBUTOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/preview-docs') }}
96+
97+
runs-on: ubuntu-latest
98+
permissions:
99+
# Needed to write a comment on the PR
100+
pull-requests: write
101+
# Needed to read the PR branch
102+
contents: read
103+
steps:
104+
- uses: actions/checkout@v4
105+
with:
106+
# Checkout the PR branch
107+
ref: refs/pull/${{ github.event.issue.number }}/head
108+
109+
- uses: r-lib/actions/setup-pandoc@v2
110+
111+
- uses: r-lib/actions/setup-r@v2
112+
with:
113+
use-public-rspm: true
114+
115+
- uses: r-lib/actions/setup-r-dependencies@v2
116+
with:
117+
extra-packages: any::pkgdown, local::.
118+
needs: website
119+
120+
- name: Build site
121+
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
122+
shell: Rscript {0}
123+
124+
- name: Deploy to Netlify
125+
uses: nwtgck/[email protected]
126+
with:
127+
# Standard config
128+
github-token: ${{ secrets.GITHUB_TOKEN }}
129+
deploy-message: "Deploy from GitHub Actions"
130+
# 'docs/' is the default directory for pkgdown::build_site()
131+
# we add 'dev' because _pkgdown.yml has 'development: mode: devel'
132+
publish-dir: './docs/dev'
133+
# Development deploys only
134+
production-deploy: false
135+
# Enable pull request comment (default)
136+
enable-pull-request-comment: true
137+
# Overwrite the pull request comment with updated link (default)
138+
overwrites-pull-request-comment: true
139+
# Don't deploy to GitHub
140+
enable-github-deployment: false
141+
# Don't update the status of the commit
142+
enable-commit-status: false
143+
# Don't comment on the commit
144+
enable-commit-comment: false
145+
env:
146+
# Netlify credentials (currently from Dmitry's account)
147+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
148+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
149+
timeout-minutes: 1

.github/workflows/style.yaml

Lines changed: 0 additions & 82 deletions
This file was deleted.

.github/workflows/test-coverage.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ on:
55
push:
66
branches: [main, dev]
77
pull_request:
8-
8+
paths:
9+
- '**.R'
10+
- '**.Rmd'
11+
- DESCRIPTION
12+
- NAMESPACE
13+
- man/**
14+
- R/**
15+
- tests/**
916
name: test-coverage
1017

1118
jobs:

0 commit comments

Comments
 (0)