CtrlK
BlogDocsLog inGet started
Tessl Logo

claylo/actionista

GitHub Actions agent skill - helps create, review, and optimize workflows with up-to-date action versions and best practices

100

Quality

100%

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

patterns-caching.mdskills/actionista/references/

Caching

Speed up workflows by caching dependencies and build outputs.

Built-in Caching

Many setup actions include built-in caching:

Node.js

- uses: actions/setup-node@v4
  with:
    node-version: '20'
    cache: 'npm'           # Also: 'yarn', 'pnpm'
    cache-dependency-path: '**/package-lock.json'

Python

- uses: actions/setup-python@v5
  with:
    python-version: '3.12'
    cache: 'pip'           # Also: 'pipenv', 'poetry'
    cache-dependency-path: '**/requirements*.txt'

Go

- uses: actions/setup-go@v5
  with:
    go-version: '1.22'
    cache: true            # Caches go mod and build cache

Java

- uses: actions/setup-java@v4
  with:
    java-version: '21'
    distribution: 'temurin'
    cache: 'maven'         # Also: 'gradle', 'sbt'

actions/cache

For custom caching needs:

- uses: actions/cache@v5
  with:
    path: ~/.npm
    key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
    restore-keys: |
      npm-${{ runner.os }}-

Required Inputs

InputDescription
pathPath(s) to cache
keyUnique cache key

Optional Inputs

InputDescriptionDefault
restore-keysFallback keysNone
enableCrossOsArchiveCross-OS restorefalse
fail-on-cache-missFail if no matchfalse
lookup-onlyCheck without restorefalse
save-alwaysSave even on failurefalse

Cache Keys

Hash Files

key: npm-${{ hashFiles('**/package-lock.json') }}
key: pip-${{ hashFiles('**/requirements.txt', '**/setup.py') }}
key: cargo-${{ hashFiles('**/Cargo.lock') }}
key: go-${{ hashFiles('**/go.sum') }}

OS-Specific

key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

Branch-Specific

key: build-${{ github.ref }}-${{ github.sha }}

Matrix-Specific

key: npm-${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}

Restore Keys

Fallback to partial matches:

- uses: actions/cache@v5
  with:
    path: ~/.npm
    key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
    restore-keys: |
      npm-${{ runner.os }}-
      npm-

Keys are tried in order until a prefix match is found.

Cache Hit Detection

- uses: actions/cache@v5
  id: cache
  with:
    path: ~/.npm
    key: npm-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
  if: steps.cache.outputs.cache-hit != 'true'
  run: npm ci

Common Cache Paths

Node.js

path: |
  ~/.npm
  node_modules

pnpm

- run: pnpm store path
  id: pnpm-store

- uses: actions/cache@v5
  with:
    path: ${{ steps.pnpm-store.outputs.stdout }}
    key: pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}

Python

path: |
  ~/.cache/pip
  .venv

Rust

path: |
  ~/.cargo/bin/
  ~/.cargo/registry/index/
  ~/.cargo/registry/cache/
  ~/.cargo/git/db/
  target/

Or use Swatinem/rust-cache:

- uses: Swatinem/rust-cache@v2

Go

path: |
  ~/go/pkg/mod
  ~/.cache/go-build

Gradle

path: |
  ~/.gradle/caches
  ~/.gradle/wrapper

Maven

path: ~/.m2/repository

Multiple Paths

- uses: actions/cache@v5
  with:
    path: |
      ~/.npm
      ~/.cache/Cypress
      node_modules
    key: deps-${{ hashFiles('**/package-lock.json') }}

Save on Failure

- uses: actions/cache@v5
  with:
    path: ~/.npm
    key: npm-${{ hashFiles('**/package-lock.json') }}
    save-always: true  # Save even if job fails

Separate Save/Restore

For more control:

- uses: actions/cache/restore@v5
  with:
    path: ~/.npm
    key: npm-${{ hashFiles('**/package-lock.json') }}

# ... do work ...

- uses: actions/cache/save@v5
  if: always()
  with:
    path: ~/.npm
    key: npm-${{ hashFiles('**/package-lock.json') }}

Cache Limits

  • Size limit: 10 GB per repository
  • Retention: 7 days unused
  • Eviction: LRU when limit reached

Cross-OS Caching

Enable for portable caches:

- uses: actions/cache@v5
  with:
    path: ~/.npm
    key: npm-${{ hashFiles('**/package-lock.json') }}
    enableCrossOsArchive: true  # Works across OS

Best Practices

1. Use Specific Keys

# Good: Specific to content
key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

# Bad: Too broad
key: npm-cache

2. Include OS in Key

key: build-${{ runner.os }}-${{ hashFiles('**/*.go') }}

3. Use Restore Keys

restore-keys: |
  npm-${{ runner.os }}-
  npm-

4. Cache After Install

- uses: actions/cache@v5
  id: cache
  with:
    path: node_modules
    key: modules-${{ hashFiles('**/package-lock.json') }}

- run: npm ci
  if: steps.cache.outputs.cache-hit != 'true'

5. Don't Cache Source

Cache dependencies, not source code.

6. Consider Build Outputs

- uses: actions/cache@v5
  with:
    path: |
      ~/.npm
      dist/       # Cached build output
    key: build-${{ github.sha }}

Troubleshooting

Cache Not Restoring

  • Check key matches exactly
  • Verify path exists
  • Check for typos in hashFiles pattern

Cache Size Too Large

  • Cache only essential directories
  • Exclude unnecessary files:
    path: |
      node_modules
      !node_modules/.cache

Cache Key Conflicts

  • Include more context in key (OS, matrix values)
  • Use more specific hash patterns

skills

actionista

actions-index.json

SKILL.md

README.md

tile.json