-
Notifications
You must be signed in to change notification settings - Fork 37
139 lines (117 loc) · 4.77 KB
/
pr-commands.yaml
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
133
134
135
136
137
138
139
# 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:
issue_comment:
types: [created]
name: Commands
jobs:
document:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
name: document
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::roxygen2
needs: pr-document
- name: Document
run: |
roxygen2::roxygenise(package.dir = 'paws.common')
shell: Rscript {0}
- name: commit
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add man/\* NAMESPACE
git commit -m 'Document'
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
style:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }}
name: style
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: r-lib/actions/setup-r@v2
- name: Install dependencies
run: install.packages("styler")
shell: Rscript {0}
- name: Style
run: |
styler::style_pkg(pkg = 'paws.common')
styler::style_pkg(pkg = 'make.paws')
shell: Rscript {0}
- name: commit
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add \*.R
git commit -m 'Style'
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/version') }}
name: version
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ github.event.comment.body }}
steps:
- uses: actions/checkout@v3
- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: r-lib/actions/setup-r@v2
- name: Version
id: version
run: |
# extract make.paws::paws_update_version to reduce the need to install make.paws
paws_update_version <- function(dir) {
var <- Sys.getenv("VERSION")
m <- regexpr("[0-9\\.]+", var)
version <- gsub('[[:punct:] ]$',"", regmatches(var, m, invert = FALSE))
cat("pkg_version=", version, "\n", sep="", file = Sys.getenv("GITHUB_OUTPUT"))
packages <- list.files(dir, full.names = T)
descriptions <- file.path(packages, "DESCRIPTION")
if (length(version) == 0) return()
for (desc in descriptions) {
lines <- readLines(desc)
found <- grepl("Version: [0-9\\.]+", lines, perl = T)
lines[found] <- gsub("[0-9\\.]+", version, lines[found])
found <- grepl("paws\\..*[0-9]+\\.[0-9]+\\.[0-9]+", lines,
perl = T)
found[found] <- !grepl("paws\\.common.*[0-9]+\\.[0-9]+\\.[0-9]+",
lines[found], perl = T)
lines[found] <- gsub("[0-9]+\\.[0-9]+\\.[0-9]+", version,
lines[found])
writeLines(lines, desc)
}
}
paws_update_version("cran")
shell: Rscript {0}
- name: commit
if: ${{ steps.version.outputs.pkg_version != '' }}
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add cran/*
git commit -m 'Update Cran Version: ${{ steps.version.outputs.pkg_version }}'
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}