Skip to content

Commit 9d41dbb

Browse files
committed
adds setup-r-icons
1 parent 6dc5829 commit 9d41dbb

File tree

3 files changed

+113
-0
lines changed

3 files changed

+113
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
on:
2+
push:
3+
branches: [main]
4+
5+
name: Test Setup R Icons
6+
7+
jobs:
8+
test-setup-r-icons:
9+
runs-on: ubuntu-latest
10+
11+
env:
12+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- uses: r-lib/actions/setup-r@v1
18+
with:
19+
use-public-rspm: true
20+
21+
- uses: tomjemmett/setup-r-icons@main
22+
with:
23+
icon-sets: fontawesome,simple_icons
24+
25+
- name: Show icons folder
26+
run: ls ~/.local/share/rpkg_icon
27+
28+
- name: Test it worked
29+
run: icons::icon_find("envelope")
30+
shell: Rscript {0}

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# setup-r-icons
2+
3+
This action downloads and installs the [`{icons}`](https://github.com/mitchelloharawild/icons) package and then optionally downloads individual icon libraries. It then caches whatever font's have been installed to improve future runtimes.
4+
5+
This action needs R to have previously been setup (e.g. with [`r-lib/actions/setup-r`](https://github.com/r-lib/actions/tree/master/setup-r)).
6+
7+
## Inputs
8+
9+
* `cache-version` - default `1`. If you need to invalidate the existing cache pass any other number and a new cache will be used.
10+
* `icon-sets` - default ''. Comma separated list of the font's to download, see below for further details
11+
12+
## Fonts
13+
14+
The font set's that are available to download can be found in the `{icons}` package, named as `download_*()`. Currently available are:
15+
* `bioicons`
16+
* `feather_icons`
17+
* `fontawesome`
18+
* `google_material`
19+
* `ionicons`
20+
* `octicons`
21+
* `simple_icons`
22+
23+
## Usage
24+
25+
``` yaml
26+
steps:
27+
- uses: actions/checkout@v2
28+
- uses: r-lib/actions/setup-r@v1
29+
- uses: tomjemmett/setup-r-icons@main
30+
with:
31+
icon-sets: fontawesome,simple_icons
32+
```

action.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 'setup-r-icons'
2+
description: 'Action to setup the icons package and download fonts'
3+
author: 'Tom Jemmett'
4+
inputs:
5+
cache-version:
6+
description: 'The version of the cache, change this from the default (1) to start over with a fresh cache'
7+
required: true
8+
default: 1
9+
icon-sets:
10+
description: 'Icon sets to download. Should be a common separated string with no whitespace. See the {icons} package for available icon sets (download_*() functions)'
11+
required: true
12+
default: ''
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Install dependencies
18+
run: |
19+
install.packages(c("remotes", "rappdirs", "gh"))
20+
remotes::install_github("mitchelloharawild/icons")
21+
shell: Rscript {0}
22+
23+
- name: Write icon-sets
24+
run: |
25+
writeLines("${{ inputs.icon-sets }}", "icon-sets.txt")
26+
shell: Rscript {0}
27+
28+
- name: Get icons path
29+
id: get-icons-path
30+
run: |
31+
cat("::set-output name=icons-path::", rappdirs::user_data_dir("rpkg_icon"), "\n", sep = "")
32+
shell: Rscript {0}
33+
34+
- name: Restore downloaded icons
35+
uses: actions/cache@v2
36+
with:
37+
path: ${{ steps.get-icons-path.outputs.icons-path }}
38+
key: ${{ runner.os }}-icons-${{ inputs.cache-version }}-${{ hashFiles('icon-sets.txt') }}
39+
40+
- name: Download fonts
41+
run: |
42+
library(icons)
43+
44+
icons <- strsplit("${{ inputs.icon-sets }}", ",")[[1]]
45+
46+
for (i in icons) {
47+
if (!icon_installed(get(i))) {
48+
get(paste0("download_", i))()
49+
}
50+
}
51+
shell: Rscript {0}

0 commit comments

Comments
 (0)