File tree 1 file changed +80
-0
lines changed 1 file changed +80
-0
lines changed Original file line number Diff line number Diff line change
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
+ push :
5
+ paths :
6
+ [
7
+ " **.[rR]" ,
8
+ " **.[qrR]md" ,
9
+ " **.[rR]markdown" ,
10
+ " **.[rR]nw" ,
11
+ " **.[rR]profile" ,
12
+ ]
13
+
14
+ name : Style
15
+
16
+ jobs :
17
+ style :
18
+ runs-on : ubuntu-latest
19
+ env :
20
+ GITHUB_PAT : ${{ secrets.GITHUB_TOKEN }}
21
+ steps :
22
+ - name : Checkout repo
23
+ uses : actions/checkout@v3
24
+ with :
25
+ fetch-depth : 0
26
+
27
+ - name : Setup R
28
+ uses : r-lib/actions/setup-r@v2
29
+ with :
30
+ use-public-rspm : true
31
+
32
+ - name : Install dependencies
33
+ uses : r-lib/actions/setup-r-dependencies@v2
34
+ with :
35
+ extra-packages : any::styler, any::roxygen2
36
+ needs : styler
37
+
38
+ - name : Enable styler cache
39
+ run : styler::cache_activate()
40
+ shell : Rscript {0}
41
+
42
+ - name : Determine cache location
43
+ id : styler-location
44
+ run : |
45
+ cat(
46
+ "location=",
47
+ styler::cache_info(format = "tabular")$location,
48
+ "\n",
49
+ file = Sys.getenv("GITHUB_OUTPUT"),
50
+ append = TRUE,
51
+ sep = ""
52
+ )
53
+ shell : Rscript {0}
54
+
55
+ - name : Cache styler
56
+ uses : actions/cache@v3
57
+ with :
58
+ path : ${{ steps.styler-location.outputs.location }}
59
+ key : ${{ runner.os }}-styler-${{ github.sha }}
60
+ restore-keys : |
61
+ ${{ runner.os }}-styler-
62
+ ${{ runner.os }}-
63
+
64
+ - name : Style
65
+ run : styler::style_pkg()
66
+ shell : Rscript {0}
67
+
68
+ - name : Commit and push changes
69
+ run : |
70
+ if FILES_TO_COMMIT=($(git diff-index --name-only ${{ github.sha }} \
71
+ | egrep --ignore-case '\.(R|[qR]md|Rmarkdown|Rnw|Rprofile)$'))
72
+ then
73
+ git config --local user.name "$GITHUB_ACTOR"
74
+ git config --local user.email "[email protected] "
75
+ git commit ${FILES_TO_COMMIT[*]} -m "Style code (GHA)"
76
+ git pull --ff-only
77
+ git push origin
78
+ else
79
+ echo "No changes to commit."
80
+ fi
You can’t perform that action at this time.
0 commit comments