Opscraft
GitHub Actions · Lesson 6 of 10 · 4 min read

Runners, caching and artifacts

Runner options

Runner Notes
GitHub-hosted (ubuntu-latest, windows-latest, macos-latest) Fresh VM per job, preinstalled tools, billed per minute (free quota for public repos); arm64 Linux runners available
Larger runners More CPU/RAM, static IPs, GPU options — paid
Self-hosted Your machines: access to private networks, custom hardware, no per-minute cost; you patch and secure them
Actions Runner Controller (ARC) Kubernetes operator that runs ephemeral, autoscaling self-hosted runners as pods on EKS (runner scale sets)
Enlarge diagramGitHub-hostedSelf-hosted (ARC on EKS)Fresh VM per job, tools preinstalledNo servers to patchBilled per minuteNo access to your private networkReach private VPC resourcesEphemeral pods, autoscaledYou patch, isolate and secure themNever for public repositories
Figure 1. Choosing runners: GitHub-hosted for most work; self-hosted when you need private network access or special hardware.
Swipe sideways to see all of it, or tap to open it full screen.

Self-hosted runner security:

  • Use ephemeral runners (one job, then destroyed) so a job can't leave malware or credentials for the next.
  • Never attach self-hosted runners to public repositories — anyone can open a PR that runs code on them.
  • Isolate by runner groups (which repos/orgs can use them), run in dedicated namespaces/accounts, give pods IRSA with minimal permissions, restrict network egress.
Enlarge diagramEKS: ARC-RUNNERS NAMESPACEGitHubjobs queuedlistenerwatches the queuerunner pod 1one job, then deletedrunner pod 2one job, then deletedrunner pod 3one job, then deleted
Figure 2. Actions Runner Controller: a scale set listens for queued jobs and starts one ephemeral runner pod per job, deleted when the job ends.
Swipe sideways to see all of it, or tap to open it full screen.

Caching

- uses: actions/cache@v4
  with:
    path: |
      ~/.gradle/caches
      ~/.gradle/wrapper
    key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
    restore-keys: gradle-${{ runner.os }}-
Enlarge diagramkeygradle-Linux-<hash ofbuild files>exact hitrestore, skip savingpartial hitrestore-keys prefixmisscold buildsaveat job end
Figure 3. How the cache key works: an exact hit restores everything; otherwise restore-keys find the closest older cache.
Swipe sideways to see all of it, or tap to open it full screen.
  • Keys usually hash lockfiles; restore-keys give partial hits.
  • Caches are scoped by branch (a branch can read caches from its base/default branch), limited in size per repo (10 GB by default, least-recently-used eviction).
  • setup-node, setup-java, setup-python and setup-go have built-in cache: options.
  • Docker layer caching: docker/build-push-action with cache-from: type=gha / cache-to: type=gha,mode=max, or a registry cache in ECR.

Artifacts

actions/upload-artifact / download-artifact pass files between jobs and keep reports/binaries after the run (default retention 90 days, configurable). Artifacts aren't a release store — publish releases to ECR, S3, GitHub Releases or an artifact repository.

Enlarge diagramjob: buildupload-artifact app.jarartifact storagekept 90 days by defaultjob: test-e2edownload-artifact
Figure 4. Jobs run on separate machines, so files are passed between them as artifacts.
Swipe sideways to see all of it, or tap to open it full screen.