Update README with accurate single-path usage examples

This commit is contained in:
2026-05-16 14:27:42 +08:00
parent d327a5b85e
commit 8cffda161a
+11 -9
View File
@@ -7,9 +7,9 @@ A Gitea Action that caches build files as `tar.xz` archives on the runner filesy
| Input | Description | Required | Default | | Input | Description | Required | Default |
|-------|-------------|----------|---------| |-------|-------------|----------|---------|
| `path` | Directory to cache | No | `~/.cache/` | | `path` | Single directory to cache | No | `~/.cache/` |
| `key-prefix` | Prefix for the cache key | Yes | — | | `key-prefix` | Prefix for the cache key | Yes | — |
| `key-file` | File to hash for the cache key | Yes | — | | `key-file` | File to hash (SHA-256) for the cache key | Yes | — |
## Outputs ## Outputs
@@ -19,9 +19,9 @@ A Gitea Action that caches build files as `tar.xz` archives on the runner filesy
## How It Works ## How It Works
1. Hashes `key-file` with SHA-256, combines with `key-prefix` as the cache key 1. Hashes `key-file` with SHA-256, combines with `key-prefix` as `<prefix>-<hash>`
2. Stores archives at `~/.cache/.cache-store/<key>.tar.xz` 2. Stores archives at `~/.cache/.cache-store/<key>.tar.xz`
3. Restores by extracting the archive, saves by creating one 3. Restores by extracting the archive to `/`, saves by creating one
## Rust Example ## Rust Example
@@ -40,12 +40,9 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: Actions/Cache@main - uses: Actions/Cache@main
with: with:
key-prefix: 'rust' key-prefix: 'cargo-registry'
key-file: 'Cargo.lock' key-file: 'Cargo.lock'
path: | path: '~/.cargo/registry'
~/.cargo/registry
~/.cargo/git
target
- name: Build - name: Build
run: cargo build --release run: cargo build --release
``` ```
@@ -56,6 +53,10 @@ jobs:
name: Build with Conditional Steps name: Build with Conditional Steps
on: push on: push
defaults:
run:
shell: bash
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -66,6 +67,7 @@ jobs:
with: with:
key-prefix: 'rust' key-prefix: 'rust'
key-file: 'Cargo.lock' key-file: 'Cargo.lock'
path: '~/.cargo/registry'
- name: Fetch dependencies - name: Fetch dependencies
if: steps.cache.outputs.cache-hit != 'true' if: steps.cache.outputs.cache-hit != 'true'
run: cargo fetch run: cargo fetch