Skip to content

File

README.md

login/README.md · 4753 bytes · Open on GitHub

# Log in to Vercel Container Registry

Part of [`vercel/vcr-action`](../README.md), a collection of GitHub Actions
for Vercel Container Registry.

GitHub Action that logs in to
[Vercel Container Registry](https://vercel.com/docs/container-registry)
(`vcr.vercel.com`) with Docker, Podman, and Buildah.

## Usage

```yaml
name: Push to VCR

on:
  push:
    branches: [main]

permissions:
  contents: read
  id-token: write

jobs:
  push:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: docker/setup-buildx-action@v3

      - name: Log in to VCR
        uses: vercel/vcr-action/login@v1
        with:
          team: ${{ vars.VERCEL_TEAM_ID }}

      - name: Build and push
        uses: docker/build-push-action@v6
        with:
          context: .
          platforms: linux/amd64
          provenance: false
          tags: vcr.vercel.com/<team-slug>/<project-slug>/<repo>:latest
          outputs: type=image,push=true,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true
```

## Prerequisites

1. [Create an OIDC policy](https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fsettings%2Fbuild-and-deployment%3FaddOidcPolicy%3Dvcr&title=Add+a+VCR+OIDC+Policy)
   on your Vercel team that grants read-write access to Vercel Container
   Registry (a VCR policy). Ensure your OIDC policy has access the project that the repository is in.
2. Store your Vercel team ID (`team_...`) as a repository **variable**
   (e.g. `VERCEL_TEAM_ID`) and give the workflow (or job) `id-token: write`
   permission.

## Inputs

| Name         | Required | Default                  | Description                                                                 |
| ------------ | -------- | ------------------------ | --------------------------------------------------------------------------- |
| `team`       | yes      |                          | Vercel team ID (`team_...`) used for the token exchange and registry login. |
| `audience`   | no       |                          | Custom OIDC audience, if your Vercel OIDC policy defines one.               |
| `policy`     | no       |                          | OIDC policy ID, to disambiguate between multiple matching policies.          |
| `engines`    | no       | `docker`                 | Engines to log in with (comma-, space-, or newline-separated): `docker`, `podman`, `buildah`. |
| `registry`   | no       | `vcr.vercel.com`         | Registry host.                                                               |
| `logout`     | no       | `true`                   | Log out from the registry when the job completes.                            |
| `revoke`     | no       | `true`                   | Revoke the access token when the job completes.                              |

## Outputs

| Name       | Description                                                                      |
| ---------- | -------------------------------------------------------------------------------- |
| `registry` | Registry host that was logged in to.                                             |
| `engines`  | Newline-separated list of engines that were logged in (docker, podman, buildah). |

Use [`wait-for-optimized-image`](../wait-for-optimized-image/README.md) to
wait for a pushed image to become ready before retagging it.

## Pushing with each engine

The repository is created automatically on first push. Repository references
have the form `vcr.vercel.com/<team-slug>/<project-slug>/<repo>:<tag>`.