Why OIDC for Container Registries?

Storing long-lived registry credentials in GitHub Secrets is a common but risky practice. If a token leaks, attackers gain persistent access to your container registry. Vercel's new vercel/vcr-action/login action solves this by leveraging GitHub OIDC to exchange a short-lived workflow token for a Vercel access token. The token is automatically revoked when the job ends.

This tutorial walks you through setting up OIDC authentication and pushing a Docker image to Vercel Container Registry (VCR) from GitHub Actions.

Developer configuring Vercel Container Registry login via GitHub Actions OIDC for secure cloud deployments IT Technology Image

Step-by-Step Implementation

1. Create an OIDC Policy on Vercel

In your Vercel team settings, create an OIDC policy that matches your GitHub repository and workflow. Grant read-write access to VCR.

2. Store Required Variables

Add the following as GitHub repository variables (not secrets, since they're not sensitive):

  • VERCEL_TEAM_ID
  • VERCEL_TEAM_SLUG
  • VERCEL_PROJECT_SLUG
  • VCR_REPOSITORY

3. Configure the Workflow

name: Push to VCR
on:
  push:
    branches: [main]

permissions:
  contents: read
  id-token: write   # Required for OIDC

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/${{ vars.VERCEL_TEAM_SLUG }}/${{ vars.VERCEL_PROJECT_SLUG }}/${{ vars.VCR_REPOSITORY }}:latest
          outputs: type=image,push=true,oci-mediatypes=true,compression=zstd,compression-level=3,force-compression=true

Note: The action authenticates Docker by default. Pass engines to use Podman or Buildah instead.

4. Use the Image in Vercel Sandbox

Once the image is pushed, you can reference it as a custom Vercel Sandbox image within the same project:

vcr.vercel.com/<team-slug>/<project-slug>/<repo>:latest

Docker image being pushed to Vercel Container Registry from a GitHub Actions workflow using short-lived tokens Technical Structure Concept

Limitations and Caveats

  • OIDC policy scope: The policy must exactly match the repository and workflow; misconfiguration leads to authentication failures.
  • Token lifetime: The Vercel token is short-lived and revoked after the job, so it cannot be reused for manual debugging.
  • Platform support: Currently the example uses linux/amd64; other architectures may require additional configuration.
  • No secrets fallback: This method replaces static credentials entirely; ensure your workflow doesn't rely on them elsewhere.

Next Steps

GitHub Actions workflow file showing OIDC permissions and VCR login step for container security Algorithm Concept Visual

Conclusion

By adopting OIDC-based authentication for Vercel Container Registry, you eliminate long-lived credentials and reduce your attack surface. The vercel/vcr-action/login action makes it straightforward to integrate into existing GitHub Actions workflows. Give it a try and streamline your container image pipeline securely.

Further reading: React Conf 2025 Key Takeaways for frontend trends that might impact your deployment strategy.

Source: Vercel Changelog

This content was drafted using AI tools based on reliable sources, and has been reviewed by our editorial team before publication. It is not intended to replace professional advice.