Skip to main content
GitHub Actions runners are in private preview. Contact support to request access.
This page covers jobs that run on sandboxes (type=sandbox) and build or push Docker images. It explains which Docker build caches work without setup, and how to push images and Buildx caches to Amazon ECR.

What works without setup

If you don’t need to share the Docker cache outside GitHub Actions, use type=gha. It needs no AWS setup:

Why ECR needs setup

Two things stand between a sandbox job and your ECR registries today:
  • Docker isn’t logged in to any registry when the job starts. Ravion doesn’t write a Docker login or credential helper for the job.
  • The job’s AWS role has no IAM policies. Each sandbox job gets an IAM role served at the instance metadata endpoint, but that role has no policies attached by default, so aws ecr get-login-password and aws-actions/amazon-ecr-login return AccessDenied with it. See AWS credentials.
So get credentials with GitHub OIDC, then log Docker in to ECR with aws-actions/amazon-ecr-login. That’s the same setup as on GitHub-hosted runners.
Planned: Ravion is working on a way to attach IAM policies to the job role from the execution environment, so jobs won’t need a separate OIDC role. Until that ships, use GitHub OIDC as shown on this page.

Push images and Buildx caches to ECR

1. Create the ECR repositories

ECR doesn’t create a repository on first push, so the image push and the cache export fail if their repositories don’t exist. The examples on this page use app for images and app-cache for the Buildx cache. Create them in the account and region you push to, or replace those names with repositories you already have:

2. Create an IAM role for the workflow

Create an IAM role that trusts GitHub’s OpenID Connect provider. GitHub’s guide, Configuring OpenID Connect in Amazon Web Services, shows how to add the provider and the trust policy. Limit the trust policy’s sub condition to the repositories, and if you like the branches or environments, that may push. Attach a policy with these actions. ecr:GetAuthorizationToken doesn’t support resource-level permissions, so it needs "Resource": "*". Scope the rest to the repositories the job pushes to and caches in:
A job that only reads a cache or pulls images needs ecr:GetAuthorizationToken, ecr:BatchCheckLayerAvailability, ecr:BatchGetImage and ecr:GetDownloadUrlForLayer.

3. Log in and build

  • amazon-ecr-login logs Docker in to your account’s registry for the region in aws-region. Both docker push and Buildx use that login, including the docker-container builder that setup-buildx-action creates.
  • ECR stores Buildx cache manifests only with image-manifest=true,oci-mediatypes=true on cache-to.
  • Keep the cache in its own repository, or under a tag that no image uses, so lifecycle policies for images don’t expire it unexpectedly.

Images for services: and container:

The runner pulls services: and container: images before any step runs, so the login above doesn’t apply to them. To use a private ECR image in those, start it with docker run or docker compose in a step after amazon-ecr-login instead. See Run services with Docker Compose.
Planned: Ravion is working on logging Docker in to your execution environment’s ECR registry before each job starts, so services: and container: images and docker push work without a login step. Until that ships, log in from the workflow as shown above.

Architecture

Sandboxes are x86_64 only, so images built on a sandbox are linux/amd64. To build linux/arm64 images, run that job on an EC2 runner with an ARM instance_size. See EC2 labels.

Moving from RunsOn

RunsOn’s extras=ecr-cache creates an ECR repository for Docker caches, sets RUNS_ON_ECR_CACHE, and logs Docker in to it. Ravion runners do none of these, so a ref built from ${{ env.RUNS_ON_ECR_CACHE }} is empty. Either:
  • Switch the cache to type=gha. The migration preview does this for cache-from and cache-to inputs of docker/build-push-action that use RUNS_ON_ECR_CACHE, using the tag as the cache scope. It leaves jobs that use RUNS_ON_ECR_CACHE anywhere else, such as in a run script, on RunsOn.
  • Keep the ECR cache. Replace ${{ env.RUNS_ON_ECR_CACHE }} with your repository URL and log in as in Push images and Buildx caches to ECR.
On RunsOn, the instance role usually supplies AWS credentials for amazon-ecr-login and ECR pushes. The migration preview lists jobs that use ECR without aws-actions/configure-aws-credentials, because they need the OIDC setup above on Ravion.

Next steps

AWS credentials

The job role, containers and GitHub OIDC.

Caching

Disk cache and Actions cache.