-
Notifications
You must be signed in to change notification settings - Fork 235
90 lines (88 loc) · 3.19 KB
/
styler-actions.yml
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
on:
issue_comment:
types: [created]
name: Commands
jobs:
style:
if: startsWith(github.event.comment.body, '/style')
name: style
runs-on: macOS-latest
steps:
- id: file_changes
uses: trilom/[email protected]
- name: list changed files
run: echo '${{ steps.file_changes.outputs.files_modified }}'
- name: work around https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- uses: actions/checkout@v4
with:
set-safe-directory: false
- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: r-lib/actions/setup-r@v2
- name: Install styler
run: |
Rscript -e 'install.packages("styler")'
- name: run styler
shell: bash
env:
FILES: ${{ join(fromJSON(steps.file_changes.outputs.files_modified), ' ') }}
run: |
for f in ${FILES}; do
if [[ "$f" == *.R || "$f" == *.Rmd ]]
then Rscript -e 'styler::style_file("'${f}'")'
fi
done
- name: commit
run: |
git add \*.R
git add \*.Rmd
if [ "$(git diff --name-only --cached)" != "" ]; then git commit -m 'automated syle update' ; fi
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
document:
if: (startsWith(github.event.comment.body, '/style') || startsWith(github.event.comment.body, '/document'))
runs-on: ubuntu-latest
container: pecan/depends:develop
steps:
- name: work around https://github.com/actions/checkout/issues/766
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- uses: actions/checkout@v4
with:
set-safe-directory: false
- uses: r-lib/actions/pr-fetch@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: update dependency lists
run: Rscript scripts/generate_dependencies.R
- name: install any new dependencies
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
working-directory: docker/depends
run: Rscript pecan.depends.R
- id: file_changes
uses: trilom/[email protected]
- name : make
shell: bash
env:
FILES: ${{ join(fromJSON(steps.file_changes.outputs.files_modified), ' ') }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
run: |
echo ${FILES} \
| tr ' ' '\n' \
| grep -e base -e models -e modules \
| cut -d / -f 1-2 \
| sort \
| uniq \
| xargs -n1 -I{} make .doc/{}
- name: commit
run: |
git config --global user.email "[email protected]"
git config --global user.name "PEcAn stylebot"
git add \*.Rd \*NAMESPACE Makefile.depends docker/depends/pecan_package_dependencies.R docker/depends/pecan_deps_from_github.txt
if [ "$(git diff --name-only --cached)" != "" ]; then git commit -m 'automated documentation update' ; fi
- uses: r-lib/actions/pr-push@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}