CI: auto-cache add option to save cache (#31076)

* save cache option

* inputs
old-commit-hash: bbbe94bc3e
This commit is contained in:
Justin Newberry
2024-01-19 15:43:47 -05:00
committed by GitHub
parent 93ac3d37cb
commit aba5ee6a44
2 changed files with 13 additions and 2 deletions

View File

@@ -0,0 +1,45 @@
name: 'automatically cache based on current runner'
inputs:
path:
description: 'path to cache'
required: true
key:
description: 'key'
required: true
restore-keys:
description: 'restore-keys'
required: true
save:
description: 'whether to save the cache'
default: 'false'
required: false
runs:
using: "composite"
steps:
- name: setup namespace cache
if: ${{ contains(runner.name, 'nsc') }}
uses: namespacelabs/nscloud-cache-action@v1
with:
path: ${{ inputs.path }}
- name: restore github cache
if: ${{ !contains(runner.name, 'nsc') }}
uses: actions/cache/restore@v3
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}
restore-keys: ${{ inputs.restore-keys }}
# make the directory manually in case we didn't get a hit, so it doesn't fail on future steps
- id: scons-cache-setup
shell: bash
run: mkdir -p ${{ inputs.path }}
- name: save github cache
if: ${{ !contains(runner.name, 'nsc') && inputs.save != 'false' }}
uses: actions/cache/save@v3
with:
path: ${{ inputs.path }}
key: ${{ inputs.key }}