GitHub Actions agent skill - helps create, review, and optimize workflows with up-to-date action versions and best practices
100
100%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Passed
No known issues
Speed up workflows by caching dependencies and build outputs.
Many setup actions include built-in caching:
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm' # Also: 'yarn', 'pnpm'
cache-dependency-path: '**/package-lock.json'- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip' # Also: 'pipenv', 'poetry'
cache-dependency-path: '**/requirements*.txt'- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true # Caches go mod and build cache- uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven' # Also: 'gradle', 'sbt'For custom caching needs:
- uses: actions/cache@v5
with:
path: ~/.npm
key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ runner.os }}-| Input | Description |
|---|---|
path | Path(s) to cache |
key | Unique cache key |
| Input | Description | Default |
|---|---|---|
restore-keys | Fallback keys | None |
enableCrossOsArchive | Cross-OS restore | false |
fail-on-cache-miss | Fail if no match | false |
lookup-only | Check without restore | false |
save-always | Save even on failure | false |
key: npm-${{ hashFiles('**/package-lock.json') }}
key: pip-${{ hashFiles('**/requirements.txt', '**/setup.py') }}
key: cargo-${{ hashFiles('**/Cargo.lock') }}
key: go-${{ hashFiles('**/go.sum') }}key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}key: build-${{ github.ref }}-${{ github.sha }}key: npm-${{ matrix.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}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.
- 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 cipath: |
~/.npm
node_modules- run: pnpm store path
id: pnpm-store
- uses: actions/cache@v5
with:
path: ${{ steps.pnpm-store.outputs.stdout }}
key: pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}path: |
~/.cache/pip
.venvpath: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/Or use Swatinem/rust-cache:
- uses: Swatinem/rust-cache@v2path: |
~/go/pkg/mod
~/.cache/go-buildpath: |
~/.gradle/caches
~/.gradle/wrapperpath: ~/.m2/repository- uses: actions/cache@v5
with:
path: |
~/.npm
~/.cache/Cypress
node_modules
key: deps-${{ hashFiles('**/package-lock.json') }}- uses: actions/cache@v5
with:
path: ~/.npm
key: npm-${{ hashFiles('**/package-lock.json') }}
save-always: true # Save even if job failsFor 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') }}Enable for portable caches:
- uses: actions/cache@v5
with:
path: ~/.npm
key: npm-${{ hashFiles('**/package-lock.json') }}
enableCrossOsArchive: true # Works across OS# Good: Specific to content
key: npm-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
# Bad: Too broad
key: npm-cachekey: build-${{ runner.os }}-${{ hashFiles('**/*.go') }}restore-keys: |
npm-${{ runner.os }}-
npm-- 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'Cache dependencies, not source code.
- uses: actions/cache@v5
with:
path: |
~/.npm
dist/ # Cached build output
key: build-${{ github.sha }}path: |
node_modules
!node_modules/.cacheskills
actionista
agents
references