---
title: OIDC Permissions for GitHub Actions
description: Let a trust policy grant the GitHub Actions jobs it matches more than CI Reporting, such as pausing the merge queue during a deploy, with no key stored in their secrets.
---

A [trust policy](/integrations/gha/oidc#trust-policies) grants the OIDC CI token of the jobs it
matches [CI Reporting](/api/application-keys#ci-reporting) by default. A GitHub organization
`Owner` can make it grant any [application key
permission](/api/application-keys#application-key-permissions) instead, or as well, on the job's own
repository.

## When to use it

Use it when a GitHub Actions job calls the Mergify API for more than its test results and scopes,
and keeps an application key in its secrets to do so: a deploy workflow that pauses the merge
queue, for instance.

## Granting permissions

Write a policy for the jobs that need more, matching as few of them as you can, rather than
widening the one your CI runs under. A job that several policies match gets what each of them
grants, so your test jobs keep CI Reporting from their own policy.

Only a GitHub organization `Owner`, signed in as themselves, creates, changes or deletes a policy
that grants more than CI Reporting.

On the [dashboard](https://dashboard.mergify.com), pick what a policy grants under **Permissions**
in its editor. In [the API](/api/ci-identity), a policy's `permissions` maps each resource it grants
to its level, such as `{"merge_queue_pause": "write"}`, and replaces CI Reporting: list
`"ci_reporting": "write"` too for jobs that upload test results.

:::caution
  Anyone who can push a branch to the policy's repositories can add a workflow it matches, and get
  its permissions. Limit the policy to an
  [environment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment)
  whose protection rules GitHub checks before the job starts. A reusable workflow pinned to a
  protected ref holds them back too, if it runs no code from the branch that calls it.
:::

In a job granted `id-token: write`, the [Mergify CLI](/cli/usage#github-actions) exchanges the job's
ID token when it has no `MERGIFY_TOKEN`, so its commands get what the job's policies grant. This
job runs in the `production` environment, which its policy names, and pauses the merge queue while
it deploys:

```yaml
jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production
    permissions:
      id-token: write
      contents: read
    steps:
      - uses: Mergifyio/setup-cli@v1
        with:
          mergify_cli_version: latest
      - name: Pause the merge queue
        run: mergify queue pause --reason "Deploying" --yes-i-am-sure
      # Your deploy steps
      - name: Resume the merge queue
        if: always()
        run: mergify queue unpause
```

A script that calls [the API](/api/ci-identity) directly exchanges the ID token itself, as
[Before you start](/integrations/gha/oidc#before-you-start) describes.

## How it behaves

- The token reaches only the operations whose path names the job's repository. An operation that
  names no repository refuses it, whatever the policy grants: use an application key for those.

- The [**Exchanges**](/integrations/gha/oidc#check-the-exchanges) tab shows what the token of each
  allowed exchange got, under **Granted**, and the API returns it under `permissions`.

## See also

- [OIDC Authentication for GitHub Actions](/integrations/gha/oidc)
- [Application key permissions](/api/application-keys#application-key-permissions)
- [Pausing the Merge Queue](/merge-queue/pause)
