awalsh128/cache-apt-pkgs-action
Über uns
Cache APT packages in GitHub Actions
EntwicklerwerkzeugeGemessener Sternzuwachs
- in 24h
- 0
- in 7 days
- -1
- in 15 days
- Verlauf wird gesammelt
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
Original
Cache APT Packages
Cache APT packages between GitHub Actions runs, so a run restores them instead of installing them again.
Cache APT packages between workflow runs, so a run restores them from the GitHub Actions cache instead of
installing them again. It is built on
@actions/cache and
ts-apt.
- ⚡ Skips the install on a cache hit and restores the packages from an archive.
- 📦 Caches the dependencies too, so the whole installed set comes back (e.g.
graphvizand the libraries it pulls in). - 🔑 Keeps one cache for each package list,
versionlabel and architecture. - 🧾 Reports the exact installed versions as outputs, for audit logs.
- 🔍 Uploads the logs and manifests as an artifact when
debugis on.
Free and open source, and kept up by one person.
If it saves you time, sponsor it monthly or
leave a small one-time tip. Every bit
helps.
[!IMPORTANT] v2 is stable. Use
@v2(or an exact release likev2.0.0) for new and existing workflows. v1 is in maintenance mode and only gets bug and reliability fixes, so use@v1only if you need what v2 dropped (e.g.add-repository). The Version 2 FAQ covers what changes.
[!NOTE] I'm looking for co-maintainers to help review changes and investigate issues. I haven't had as much time for this action as I would like, and I want it to stay responsive for the community. Reach out if you are interested.
Quick Start
steps:
- uses: awalsh128/[email protected]
with:
packages: graphviz doxygen
version: 1.0
Change version to start a fresh cache (e.g. after a runner image change).
Requirements
A Linux runner with APT (e.g. GitHub-hosted ubuntu-latest). The action runs on node24, so self-hosted
runners need a runner version that supports it. GitHub-hosted runners already do.
Configuration
Inputs
| Name | Description | Required | Default |
|---|---|---|---|
packages |
Space delimited list of packages to install. Pin a version with APT syntax (e.g. xdot=1.2-2). |
Yes | |
version |
Cache version label. Each label has its own cache, so change it to start a fresh one. It can't contain spaces. | No | "" |
execute_install_scripts |
Run each package's preinst and postinst script after a restore. See Non-file dependencies. |
No | false |
empty_packages_behavior |
What to do when packages is empty: error fails the action, warn logs a warning and skips, ignore skips quietly. |
No | error |
debug |
Log more detail and upload the logs and manifests as a workflow artifact (a failed run uploads them anyway). Costs a little time. | No | false |
Outputs
| Name | Description |
|---|---|
cache-hit |
true when a cache was found for the packages requested. |
package-version-list |
The requested packages and the versions installed, as a sorted comma list (e.g. curl=8.5.0,jq=1.7.1). A package for a non-native architecture includes it (e.g. libc6:i386=2.39). |
all-package-version-list |
The same format for every package installed, dependencies included. |
Versions
@v2is the latest stable v2 release. It moves on each stable release, and it is the only tag that ever moves.@v#.#.#is an exact release (e.g.v2.0.0). It never changes once published. Release candidates, cut fromstaging-2after CI passes, are taggedv#.#.#-rc.#and may be unstable.@v2never points at one.@v1is the last v1 release line, in maintenance mode on the frozenmasterbranch.- A full commit SHA pins the exact code and is the safest choice.
A tag that moves lets a compromised release change what your workflow runs. If that matters to you, pin an
exact release or a commit SHA instead of @v2. @latest and @v1 are moving tags too, and they only point
at v1.
Version 1 is maintained on the frozen master branch. Version 2 is released from tags only. The main-2 and
staging-2 branches hold source without the built dist/, so do not use them as uses: refs.
Cache scopes
The cache is scoped to the packages given and the ref that saved it. A run can restore caches from its own
branch or tag and from the default branch. Tags do not share caches with each other, so a workflow that only
runs on tag pushes (e.g. releases) misses every time. To share a cache across tags, run the action with the
same packages and version on the default branch (e.g. on push or on a schedule).
GitHub evicts the oldest caches when a repository goes over its storage limit (10 GB by default), and any
cache that goes a week without being used. A large package set (e.g. texlive-full) can be evicted before the
next run. See
Managing caches
to inspect yours.
Example workflow
This was the motivating use case for the action.
name: Create Documentation
on: push
jobs:
build_and_deploy_docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: awalsh128/[email protected]
with:
packages: dia doxygen doxygen-doc doxygen-gui doxygen-latex graphviz mscgen
version: 1.0
- name: Build
run: |
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Deploy
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: ${{github.workspace}}/build/website
For stricter setups (e.g. pinned package versions or minimal permissions), see Hardening.
⚠️ Caveats
A restore only extracts files, so some packages need more than that. See Caveats for the details and the fixes.
- Non-file dependencies: the Debian package database and triggers
aren't updated. Set
execute_install_scriptsor install that package in its own step. - Runner image changes: the cache key doesn't include the runner
image. Put
ImageOSandImageVersionintoversion. - Stalled mirrors: a cache miss can stall on the default Ubuntu mirror.
Point
aptatarchive.ubuntu.com.
See CONTRIBUTING.md if you want to help.
Ähnliche Projekte entdecken
Wird geladen…