forked from spacetelescope/romanisim
-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (35 loc) · 1.34 KB
/
retrieve_cache.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
name: retrieve latest data cache key
on:
workflow_call:
inputs:
cache_path:
type: string
required: false
default: ""
outputs:
cache_key:
value: ${{ jobs.retrieve_cache.outputs.cache_key }}
cache_path:
value: ${{ jobs.retrieve_cache.outputs.cache_path }}
jobs:
retrieve_cache:
name: retrieve latest data cache key
runs-on: ubuntu-latest
steps:
- id: cache_path
run: echo cache_path=${{ inputs.cache_path != '' && inputs.cache_path || format('{0}/data', runner.temp) }} >> $GITHUB_OUTPUT
- name: retrieve latest data cache key
id: latest_cache_key
run: |
# use actions/gh-actions-cache to allow filtering by key
gh extension install actions/gh-actions-cache
CACHE_KEY=$(gh actions-cache list -R ${{ github.repository }} --key data- --sort created-at | cut -f 1 | head -n 1)
if [ "$CACHE_KEY" == '' ]; then exit 1; fi
echo cache_key=$CACHE_KEY >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
- run: echo cache_key=${{ steps.latest_cache_key.outputs.cache_key }}
- run: echo cache_path=${{ steps.cache_path.outputs.cache_path }}
outputs:
cache_key: ${{ steps.latest_cache_key.outputs.cache_key }}
cache_path: ${{ steps.cache_path.outputs.cache_path }}