Runner caches
Each repository gets a cache disk that pols-checkout and pols-docker-builder keep a Git mirror and BuildKit's layers on, so jobs fetch only new commits and rebuild only changed Docker layers.
Jobs on pols runners start in fresh sandboxes, so by default every job clones the repository and builds its Docker images from scratch. Two public actions keep that work on a cache disk of the repository’s own instead:
| Action | Replaces | Keeps on the cache |
|---|---|---|
PEWEO/pols-checkout@v1 |
actions/checkout |
a bare Git mirror of the repository |
PEWEO/pols-docker-builder@v1 and PEWEO/pols-docker-builder/build@v1 |
docker/setup-buildx-action and docker/build-push-action |
BuildKit’s state, with its layers |
jobs:
image:
runs-on: pols-default
steps:
- uses: PEWEO/pols-checkout@v1
- uses: PEWEO/pols-docker-builder@v1
- uses: PEWEO/pols-docker-builder/build@v1
with:
push: true
tags: ghcr.io/acme/app:latest
Both take the inputs of the action they replace and give its outputs, plus cached. Anywhere else (GitHub’s runners, your own) they are that action, with the same inputs, so one workflow can run on both. The wizard makes these changes for you.
How the cache works
- A copy per job. When a job starts on a pols runner, pols makes a copy of the repository’s cache disk on the runner’s host, attaches it to the sandbox and mounts it at
/mnt/pols-cache. The runner’s environment hasPOLS_CACHE_STATUS=/run/pols-cache.json, a file that says whether the cache is ready, so the actions wait for it (up tocache-waitseconds, 60 by default). A new cache is an empty 50 GiB volume. - Kept when the job succeeds. When the job is over, its copy becomes the repository’s cache if the job succeeded and wrote to it; otherwise the copy is dropped. Of several jobs, the last copy kept wins.
- Never written by forks. Jobs of a pull request from a fork read the cache but never write to it: their copy is always dropped. See security.
- Per repository and host. A cache belongs to one repository of one org, on one host. Jobs of the same repository on another host use that host’s cache, and a renamed repository starts a new one.
- Only where it is used. A cache no job ever kept is deleted with its last copy, so a repository that does not use the actions has no cache and pays nothing for one.
- Expiry. A cache no job has used for 7 days is deleted.
- Billing. A cache is billed as disk at the rate card.
A runner that pols placed in Incus instead of Cloud Hypervisor has no cache; its status file says so, and the actions fall back to the actions they replace.
Git checkout
PEWEO/pols-checkout@v1 keeps a bare mirror of the repository at /mnt/pols-cache/git/<owner>/<name>.git, fetches every branch and tag into it, and checks out the job’s commit from it. The first job of a repository clones it once; every job after that fetches only the commits pushed since, and the working copy reads its objects from the mirror instead of copying them.
- uses: PEWEO/pols-checkout@v1
- The mirror has the whole history, so
fetch-depthmakes no difference to speed. Withfetch-depth: 0orfetch-tags: true, the working copy sees every branch or tag, as withactions/checkout. ssh-key,filter,sparse-checkout,lfsandsubmoduleshand the checkout toactions/checkout, as does a cached checkout that fails.
Inputs
The inputs of actions/checkout, with its defaults, plus cache-wait:
| Input | Default | Description |
|---|---|---|
repository |
${{ github.repository }} |
Repository name with owner, for example actions/checkout |
ref |
The branch, tag or SHA to check out; defaults to the reference or SHA of the event that triggered the workflow | |
token |
${{ github.token }} |
Token used to fetch the repository |
ssh-key |
SSH key used to fetch the repository (checked out by actions/checkout) |
|
ssh-known-hosts |
Known hosts in addition to the user and global host key database | |
ssh-strict |
true |
Whether to perform strict host key checking |
ssh-user |
git |
The user to use when connecting to the remote SSH host |
persist-credentials |
true |
Whether to configure the token with the local git config |
path |
Relative path under $GITHUB_WORKSPACE to place the repository |
|
clean |
true |
Whether to run git clean -ffdx && git reset --hard HEAD before fetching |
filter |
Partially clone against a given filter (checked out by actions/checkout) |
|
sparse-checkout |
Do a sparse checkout on given patterns (checked out by actions/checkout) |
|
sparse-checkout-cone-mode |
true |
Whether to use cone mode for a sparse checkout |
fetch-depth |
1 |
Number of commits to fetch; 0 fetches all history for all branches and tags. The cache’s mirror always has all history |
fetch-tags |
false |
Whether to fetch tags, even if fetch-depth > 0 |
show-progress |
true |
Whether to show progress while fetching |
lfs |
false |
Whether to download Git LFS files (checked out by actions/checkout) |
submodules |
false |
Whether to check out submodules, true or recursive (checked out by actions/checkout) |
set-safe-directory |
true |
Add the repository path as safe.directory in the global Git config |
github-server-url |
The base URL of the GitHub instance to clone from | |
allow-unsafe-pr-checkout |
false |
Passed to actions/checkout |
cache-wait |
60 |
Seconds to wait for pols to say whether the job has a cache |
Outputs
| Output | Description |
|---|---|
ref |
The branch, tag or SHA that was checked out |
commit |
The commit SHA that was checked out |
cached |
Whether the checkout came from the pols runner cache (true or false) |
Docker builds
PEWEO/pols-docker-builder@v1 starts BuildKit next to the job, with its state in /mnt/pols-cache/buildkit, and makes it the job’s Buildx builder, so a build redoes only the steps whose inputs changed. No registry or type=gha cache needs setting up. BuildKit is a pinned release, checked against its published SHA-256 and kept on the cache.
PEWEO/pols-docker-builder/build@v1 builds and pushes like docker/build-push-action. Used on its own, it sets up the cached builder first, so replacing only build-push-action works too.
- uses: PEWEO/pols-docker-builder@v1 # optional when build follows
- uses: PEWEO/pols-docker-builder/build@v1
with:
context: .
push: true
tags: ghcr.io/acme/app:${{ github.sha }}
- BuildKit collects garbage by the cache’s size: it keeps at most three fifths of the disk for layers.
type=ghaentries incache-fromandcache-toare left out while the cache is in use; other cache sources and destinations are passed on.driveranddriver-optsdo not apply on a pols runner.
Builder inputs
PEWEO/pols-docker-builder@v1 takes the inputs of docker/setup-buildx-action, with its defaults, plus cache-wait:
| Input | Default | Description |
|---|---|---|
version |
Buildx version (off pols runners; pols runners use the image’s) | |
driver |
docker-container |
Builder driver (off pols runners; pols runners run BuildKit next to the job) |
driver-opts |
Driver options (off pols runners) | |
buildkitd-flags |
Flags for buildkitd | |
buildkitd-config |
BuildKit daemon config file | |
buildkitd-config-inline |
Inline BuildKit daemon config | |
use |
true |
Switch to this builder instance |
name |
Name of the builder | |
endpoint |
Docker context or endpoint for the node (off pols runners) | |
platforms |
Fixed platforms for the node, comma-separated | |
append |
Nodes to append to the builder (off pols runners) | |
keep-state |
false |
Keep BuildKit state on cleanup (off pols runners; on pols runners the state is the cache) |
cache-binary |
true |
Cache the buildx binary (off pols runners) |
cleanup |
true |
Clean up state on job end (off pols runners) |
cache-wait |
60 |
Seconds to wait for pols to say whether the job has a cache |
Builder outputs
| Output | Description |
|---|---|
name |
Builder name |
driver |
Builder driver |
platforms |
Builder node platforms |
nodes |
Builder nodes metadata |
endpoint |
Builder node endpoint |
status |
Builder node status |
flags |
Builder node flags |
cached |
Whether the builder keeps its layers on the pols runner cache (true or false) |
Build inputs
PEWEO/pols-docker-builder/build@v1 takes the inputs of docker/build-push-action, with its defaults, plus cache-wait:
| Input | Default | Description |
|---|---|---|
add-hosts |
List of custom host-to-IP mappings (for example docker:10.180.0.1) |
|
allow |
List of extra privileged entitlements (for example network.host,security.insecure) |
|
annotations |
List of annotations to set on the image | |
attests |
List of attestation parameters (for example type=sbom,generator=image) |
|
build-args |
List of build-time variables | |
build-contexts |
List of additional build contexts (for example name=path) |
|
builder |
Builder instance | |
cache-from |
List of external cache sources; type=gha entries are left out while the pols cache is in use |
|
cache-to |
List of cache export destinations; type=gha entries are left out while the pols cache is in use |
|
call |
Method for evaluating the build (for example check) |
|
cgroup-parent |
Parent cgroup for the container used in the build | |
context |
The build’s context: the files at the given path or URL | |
file |
Path to the Dockerfile | |
labels |
List of metadata for the image | |
load |
false |
Shorthand for --output=type=docker |
network |
Networking mode for the RUN instructions during the build |
|
no-cache |
false |
Do not use the cache when building the image |
no-cache-filters |
Do not cache the given stages | |
outputs |
List of output destinations (format: type=local,dest=path) |
|
platforms |
List of target platforms for the build | |
provenance |
Generate a provenance attestation (shorthand for --attest=type=provenance) |
|
pull |
false |
Always attempt to pull all referenced images |
push |
false |
Shorthand for --output=type=registry |
sbom |
Generate an SBOM attestation (shorthand for --attest=type=sbom) |
|
secrets |
List of secrets to expose to the build (for example key=string) |
|
secret-envs |
List of secret environment variables to expose to the build (for example key=envname) |
|
secret-files |
List of secret files to expose to the build (for example key=filename) |
|
shm-size |
Size of /dev/shm (for example 2g) |
|
ssh |
List of SSH agent sockets or keys to expose to the build | |
tags |
List of tags | |
target |
The target stage to build | |
ulimit |
Ulimit options (for example nofile=1024:1024) |
|
github-token |
${{ github.token }} |
GitHub token used to authenticate against a repository for a Git context |
cache-wait |
60 |
Seconds to wait for pols to say whether the job has a cache |
Build outputs
| Output | Description |
|---|---|
imageid |
Image ID |
digest |
Image digest |
metadata |
Build result metadata |