Files
cache/action.yml
Rik Huijzer 905462d72f Extend cache action (#4)
* Extend cache action

* Also test on Windows and macOS

* Fix a problem with setting output on Windows

* Use echo after set-output

* Generate key only once

* Fix non-matching name (should fail but doesn't weirdly)

* Update action.yml

Co-authored-by: Sascha Mann <git@mail.saschamann.eu>

* Update action.yml

Co-authored-by: Sascha Mann <git@mail.saschamann.eu>

Co-authored-by: Sascha Mann <git@mail.saschamann.eu>
2021-12-27 21:52:42 +01:00

61 lines
2.0 KiB
YAML

name: 'Cache Julia artifacts, packages and registry'
description: 'Cache Julia using actions/cache'
author: 'Sascha Mann, Rik Huijzer, and contributors'
branding:
icon: 'archive'
color: 'purple'
inputs:
cache-name:
description: 'Name used as part of the cache keys'
default: 'julia-cache'
cache-artifacts:
description: 'Whether to cache artifacts'
default: 'true'
cache-packages:
description: 'Whether to cache packages'
default: 'true'
cache-registry:
description: 'Whether to cache the registry'
default: 'false'
outputs:
cache-hit:
description: 'A boolean value to indicate an exact match was found for the primary key. Returns \"\" when the key is new. Forwarded from actions/cache'
value: ${{ steps.hit.outputs.cache-hit }}
runs:
using: 'composite'
steps:
- id: paths
run: |
PATHS=""
[ "$CACHE_ARTIFACTS" = "true" ] && PATHS="${PATHS}~/.julia/artifacts"$'\n'
[ "$CACHE_PACKAGES" = "true" ] && PATHS="${PATHS}~/.julia/packages"$'\n'
[ "$CACHE_REGISTRY" = "true" ] && PATHS="${PATHS}~/.julia/registry"$'\n'
if [ "$PATHS" = "" ]; then
echo "::error title=Invalid inputs::At least one of cache-artifacts, cache-packages or cache-registry has to be true"
exit 1
fi
echo "::set-output name=cache-paths::$PATHS"
env:
CACHE_ARTIFACTS: ${{ inputs.cache-artifacts }}
CACHE_PACKAGES: ${{ inputs.cache-packages }}
CACHE_REGISTRY: ${{ inputs.cache-registry }}
shell: bash
- uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed
id: cache
with:
path: ${{ steps.paths.outputs.cache-paths }}
key: ${{ runner.os }}-test-${{ inputs.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ inputs.cache-name }}-
- id: hit
run: echo "::set-output name=cache-hit::$(echo $CACHE_HIT)"
env:
CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}
shell: bash