Skip to content

Commit

Permalink
Create action.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
Ballwictb authored Feb 25, 2024
1 parent abf459e commit 560dd30
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'setup-r-icons'
description: 'Action to setup the icons package and download fonts'
author: 'Tom Jemmett'
inputs:
cache-version:
description: 'The version of the cache, change this from the default (1) to start over with a fresh cache'
required: true
default: 1
icon-sets:
description: 'Icon sets to download. Should be a common separated string with no whitespace. See the {icons} package for available icon sets (download_*() functions)'
required: true
default: ''

runs:
using: "composite"
steps:
- name: Install dependencies
run: |
install.packages(c("remotes", "rappdirs", "gh"))
remotes::install_github("mitchelloharawild/icons")
shell: Rscript {0}

- name: Write icon-sets
run: |
writeLines("${{ inputs.icon-sets }}", "icon-sets.txt")
shell: Rscript {0}

- name: Get icons path
id: get-icons-path
run: |
cat("::set-output name=icons-path::", rappdirs::user_data_dir("rpkg_icon"), "\n", sep = "")
shell: Rscript {0}

- name: Restore downloaded icons
uses: actions/cache@v2
with:
path: ${{ steps.get-icons-path.outputs.icons-path }}
key: ${{ runner.os }}-icons-${{ inputs.cache-version }}-${{ hashFiles('icon-sets.txt') }}

- name: Download fonts
run: |
library(icons)
icons <- strsplit("${{ inputs.icon-sets }}", ",")[[1]]
for (i in icons) {
if (!icon_installed(get(i))) {
get(paste0("download_", i))()
}
}
shell: Rscript {0}

0 comments on commit 560dd30

Please sign in to comment.