Llim.run

Authenticate GitHub Actions with workload identity federation

A GitHub Actions job can request an OIDC token from GitHub and exchange it for a short-lived Limrun access token. Your repositories then need no LIM_API_KEY secret, and you control which repositories and branches get which permissions.

Before you start

You need:

Create the provider

GitHub signs tokens for every repository on GitHub, so the provider condition must check that a token comes from your organization.

  1. Open console.limrun.com, go to Settings, then Workload identity federation, and click the + button next to Identity providers.

  2. In Issuer, choose GitHub Actions. The preset fills in the issuer https://token.actions.githubusercontent.com and its signing keys.

  3. Keep Token audience as limrun. The workflow requests its token with this audience.

  4. In Provider condition (CEL), replace OWNER_ID with your organization's or user's numeric ID:

    assertion.repository_owner_id == 'OWNER_ID'

    GitHub sends IDs as strings, so keep the quotes. Use the ID rather than the name, because an organization can be renamed and its old name claimed by someone else.

  5. Click Create provider.

Create a binding

  1. In the provider's card, click the + button next to Bindings.

  2. Enter a name and a Claim condition (CEL) that selects the workflows to trust. For example, this admits only the main branch of one repository:

    assertion.repository_id == 'REPOSITORY_ID' && assertion.ref == 'refs/heads/main'

    Run gh api repos/YOUR_ORG/YOUR_REPO --jq .id to find the repository ID.

  3. Enter the permissions the workflows need, one per line, such as xcode:*:all.

  4. Click Create binding, expand Setup, and copy the binding ID.

  5. In GitHub, add the binding ID as a repository or organization variable named LIMRUN_BINDING_ID. It is not a secret.

Use the token in a workflow

GitHub's tokens are short-lived, and a Limrun access token never outlives the token it was exchanged for. This job writes a fresh token to a file every two minutes in the background, and the CLI reads the file again whenever it renews its Limrun token:

.github/workflows/limrun.yml
name: Limrun
on: push
permissions:
  id-token: write
  contents: read
jobs:
  build:
    runs-on: ubuntu-latest
    env:
      LIMRUN_WORKLOAD_IDENTITY_BINDING_ID: ${{ vars.LIMRUN_BINDING_ID }}
      LIMRUN_WORKLOAD_IDENTITY_TOKEN_FILE: ${{ runner.temp }}/limrun.jwt
    steps:
      - uses: actions/checkout@v4
      - run: npm install --global lim
      - name: Keep a GitHub token for Limrun
        run: |
          refresh() {
            curl -sS --fail-with-body -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
              "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=limrun" | jq -r .value > "$LIMRUN_WORKLOAD_IDENTITY_TOKEN_FILE.tmp"
            mv "$LIMRUN_WORKLOAD_IDENTITY_TOKEN_FILE.tmp" "$LIMRUN_WORKLOAD_IDENTITY_TOKEN_FILE"
          }
          refresh
          (while sleep 120; do refresh; done) &
      - run: lim whoami

id-token: write lets the job request tokens from GitHub, and contents: read keeps checkout working. ACTIONS_ID_TOKEN_REQUEST_URL and ACTIONS_ID_TOKEN_REQUEST_TOKEN are set by GitHub, and &audience=limrun must match the provider's audience. Writing to a temporary file and renaming it means the CLI never reads a half-written token. After lim whoami shows your organization and the binding's permissions, replace it with your build steps.

In a Node script, the @actions/core package can return the token for the TypeScript SDK on every exchange: new Limrun({ workloadToken: () => core.getIDToken('limrun'), bindingId }).

Things to know

See GitHub's OIDC reference for every claim in the token.