View as Markdown

OIDC Permissions for GitHub Actions

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 grants the OIDC CI token of the jobs it matches CI Reporting by default. A GitHub organization Owner can make it grant any application key permission instead, or as well, on the job’s own repository.

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.

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, pick what a policy grants under Permissions in its editor. In the API, 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.

In a job granted id-token: write, the Mergify CLI 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 directly exchanges the ID token itself, as Before you start describes.

  • 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 tab shows what the token of each allowed exchange got, under Granted, and the API returns it under permissions.

Was this page helpful?