Skip to content

Local Cache on Self-hosted Runner

Actions
Cache dependencies and build outputs to improve workflow execution time on self hosted machine
v3
Latest
Star (56)

Local Cache action

This action allows caching dependencies and build outputs to improve workflow execution time on self hosted machine. Artifacts are cached in the /home/ubuntu/.cache by default.

What's New

v2

  • Caches that have not been accessed over 7 days are cleaned up automatically at post action stage by clean-key.

See the v1 README.md for older updates.

Usage

Pre-requisites

Create a workflow .yml file in your repository's .github/workflows directory.

Inputs

Parameter Required/Optional Description Default
path Required A directory to save and restore cache. -
key Required An explicit key for a cache. -
base Optional A base directory to save and restore cache. /home/ubuntu/.cache
clean-key Optional If set, caches that have not been accessed over 7 days are cleaned up automatically at post action stage by clean-key. -

Outputs

Output Description
cache-hit Cache hit or not

Example cache workflow

Restoring and saving cache using a single action

name: Caching Primes

on: push

jobs:
  build:
    runs-on: [self-hosted]

    steps:
      - uses: actions/checkout@v3

      - name: Cache dependencies
        id: cache
        uses: corca-ai/local-cache@v2
        with:
          path: path/to/dependencies
          key: ${{ hashFiles('**/lockfiles') }}

      - name: Install dependencies
        if: steps.cache.outputs.cache-hit != 'true'
        run: /install.sh

      - name: Use dependencies
        run: /run.sh

Cache Limits

Cache limits are defined by the disk space of self-hosted runners. Caches that have not been accessed over 7 days can be cleaned up at post action stage by clean-key, but if you still run out of disk space, you need to manage runners by increasing disk capacity or removing cache on your own.

Local Cache on Self-hosted Runner is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Cache dependencies and build outputs to improve workflow execution time on self hosted machine
v3
Latest

Local Cache on Self-hosted Runner is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.