Skip to content

Commit 440cd86

Browse files
committed
Add PR command workflow
1 parent ea704b8 commit 440cd86

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

.github/workflows/pr-commands.yaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
name: Commands
8+
9+
jobs:
10+
document:
11+
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
12+
name: document
13+
runs-on: ubuntu-latest
14+
env:
15+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: r-lib/actions/pr-fetch@v2
20+
with:
21+
repo-token: ${{ secrets.GITHUB_TOKEN }}
22+
23+
- uses: r-lib/actions/setup-r@v2
24+
with:
25+
use-public-rspm: true
26+
27+
- uses: r-lib/actions/setup-r-dependencies@v2
28+
with:
29+
extra-packages: any::roxygen2
30+
needs: pr-document
31+
32+
- name: Document
33+
run: roxygen2::roxygenise()
34+
shell: Rscript {0}
35+
36+
- name: commit
37+
run: |
38+
git config --local user.name "$GITHUB_ACTOR"
39+
git config --local user.email "[email protected]"
40+
git add man/\* NAMESPACE
41+
git commit -m 'Document'
42+
43+
- uses: r-lib/actions/pr-push@v2
44+
with:
45+
repo-token: ${{ secrets.GITHUB_TOKEN }}
46+
47+
style:
48+
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }}
49+
name: style
50+
runs-on: ubuntu-latest
51+
env:
52+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- uses: r-lib/actions/pr-fetch@v2
57+
with:
58+
repo-token: ${{ secrets.GITHUB_TOKEN }}
59+
60+
- uses: r-lib/actions/setup-r@v2
61+
62+
- name: Install dependencies
63+
run: install.packages("styler")
64+
shell: Rscript {0}
65+
66+
- name: Style
67+
run: styler::style_pkg()
68+
shell: Rscript {0}
69+
70+
- name: commit
71+
run: |
72+
git config --local user.name "$GITHUB_ACTOR"
73+
git config --local user.email "[email protected]"
74+
git add \*.R
75+
git commit -m 'Style'
76+
77+
- uses: r-lib/actions/pr-push@v2
78+
with:
79+
repo-token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)