Files
Cache/README.md
T
saru 3a3c4d55e0 Simplify to local tar.xz filesystem cache, remove API dependency
- Store cache as tar.xz archives on runner filesystem at ~/.cache/.cache-store/
- No external API calls, no node.js, no curl needed
- Restore extracts archive if key matches, save creates one on miss
- Drastically simpler and more reliable for self-hosted runners
2026-05-16 14:10:29 +08:00

75 lines
1.6 KiB
Markdown

Cache Action
============
A Gitea Action that caches build files as `tar.xz` archives on the runner filesystem. Simple, fast, no external dependencies.
## Inputs
| Input | Description | Required | Default |
|-------|-------------|----------|---------|
| `path` | Directory to cache | No | `~/.cache/` |
| `key-prefix` | Prefix for the cache key | Yes | — |
| `key-file` | File to hash for the cache key | Yes | — |
## Outputs
| Output | Description |
|--------|-------------|
| `cache-hit` | `true` if exact key match found, `false` otherwise |
## How It Works
1. Hashes `key-file` with SHA-256, combines with `key-prefix` as the cache key
2. Stores archives at `~/.cache/.cache-store/<key>.tar.xz`
3. Restores by extracting the archive, saves by creating one
## Rust Example
```yaml
name: Rust Build
on: push
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Actions/Cache@main
with:
key-prefix: 'rust'
key-file: 'Cargo.lock'
path: |
~/.cargo/registry
~/.cargo/git
target
- name: Build
run: cargo build --release
```
## Skip Steps on Cache Hit
```yaml
name: Build with Conditional Steps
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Actions/Cache@main
id: cache
with:
key-prefix: 'rust'
key-file: 'Cargo.lock'
- name: Fetch dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: cargo fetch
- name: Build
run: cargo build --release
```