Convert main to README-only branch, update usage to reference @restore and @save branches
This commit is contained in:
@@ -3,6 +3,13 @@ Cache Action
|
||||
|
||||
A Gitea Action that caches build files as `tar.xz` archives on the runner filesystem. Simple, fast, no external dependencies.
|
||||
|
||||
## Branches
|
||||
|
||||
| Branch | Purpose |
|
||||
|--------|---------|
|
||||
| `restore` | Restores cache archive if it exists |
|
||||
| `save` | Saves cache archive (use after build) |
|
||||
|
||||
## Inputs
|
||||
|
||||
| Input | Description | Required | Default |
|
||||
@@ -15,20 +22,20 @@ A Gitea Action that caches build files as `tar.xz` archives on the runner filesy
|
||||
|
||||
| Output | Description |
|
||||
|--------|-------------|
|
||||
| `cache-hit` | `true` if exact key match found, `false` otherwise |
|
||||
| `cache-hit` | `true` if exact key match found, `false` otherwise (restore only) |
|
||||
|
||||
## How It Works
|
||||
|
||||
1. Hashes `key-file` with SHA-256, combines with `key-prefix` as `<prefix>-<hash>`
|
||||
2. Stores archives at `~/.cache/.cache-store/<key>.tar.xz`
|
||||
3. Restores by extracting the archive to `/`, saves by creating one
|
||||
3. `restore` branch extracts the archive, `save` branch creates one
|
||||
|
||||
## Usage
|
||||
|
||||
This action must be used **twice** in your workflow:
|
||||
|
||||
1. **Before build** — restores cache if it exists
|
||||
2. **After build** — saves the cache archive (only on cache miss)
|
||||
1. **Before build** — use `@restore` to restore cache if it exists
|
||||
2. **After build** — use `@save` to save the cache archive
|
||||
|
||||
## Rust Example
|
||||
|
||||
@@ -47,7 +54,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# 1. Restore cache before build
|
||||
- uses: Actions/Cache@main
|
||||
- uses: Actions/Cache@restore
|
||||
id: cache
|
||||
with:
|
||||
key-prefix: 'cargo-registry'
|
||||
@@ -58,7 +65,7 @@ jobs:
|
||||
run: cargo build --release
|
||||
|
||||
# 2. Save cache after build
|
||||
- uses: Actions/Cache@main
|
||||
- uses: Actions/Cache@save
|
||||
with:
|
||||
key-prefix: 'cargo-registry'
|
||||
key-file: 'Cargo.lock'
|
||||
@@ -82,7 +89,7 @@ jobs:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
# 1. Restore cache
|
||||
- uses: Actions/Cache@main
|
||||
- uses: Actions/Cache@restore
|
||||
id: cache
|
||||
with:
|
||||
key-prefix: 'rust'
|
||||
@@ -97,7 +104,7 @@ jobs:
|
||||
run: cargo build --release
|
||||
|
||||
# 2. Save cache
|
||||
- uses: Actions/Cache@main
|
||||
- uses: Actions/Cache@save
|
||||
with:
|
||||
key-prefix: 'rust'
|
||||
key-file: 'Cargo.lock'
|
||||
|
||||
Reference in New Issue
Block a user