Skip to main content
This guide explains how to configure Workload Identity for GitHub Actions to authenticate with Bytebase without storing long-lived credentials.

Step 1: Create a Workload Identity in Bytebase

  1. Go to IAM & Admin > Workload Identities and click Create. For an identity scoped to one project, go to the project’s Manage > Workload Identities instead.
  2. Fill in the configuration:
  1. Click Create.
Bytebase builds the Subject Pattern from the organization, repository, and branch: repo:my-org/my-repo:ref:refs/heads/main. Leaving the branch empty gives repo:my-org/my-repo:*, and leaving the repository empty gives repo:my-org/*. Advanced Settings shows the pattern and the Issuer URL (https://token.actions.githubusercontent.com); edit the pattern there to match other refs, such as a tag or an environment. See Configuration for the rules every setting must satisfy.
On GitHub Enterprise Server, the token issuer and the default audience differ from GitHub.com. Set Issuer URL under Advanced Settings to your server’s issuer, and list the audience your getIDToken() call requests.

Step 2: Assign Roles

The Roles you picked in Step 1 are granted when the identity is created, so nothing more is needed for a new identity. To change its roles later, or if the Roles field was not shown because your account cannot set the IAM policy, grant them from the project:
  1. Go to your project’s Settings > Members.
  2. Click Grant Access.
  3. Enter the Workload Identity email (e.g., github-actions-deploy@workload.bytebase.com).
  4. Select the GitOps Service Agent role.
  5. Click Confirm.
The GitOps Service Agent role is designed for automated CI/CD workflows, allowing the identity to create and execute database changes. See Roles and Permissions for details.

Step 3: Configure GitHub Actions Workflow

In your GitHub Actions workflow, add the following configuration:

Request OIDC Token

Add id-token: write permission and use the actions/github-script action to get the token:

Complete Example

Here’s a complete workflow that creates a database change using Workload Identity:

Troubleshooting

Token Exchange Fails

If the token exchange returns an error:
  1. Verify the repository and branch: Check that the workflow’s repository and branch match the Subject Pattern shown under Advanced Settings.
  2. Check the audience: The aud your getIDToken() call requests must be on the identity’s Audience list. This guide requests https://github.com/{owner}; workflows generated on the project GitOps page request bytebase.
  3. Upgraded from 3.22 or earlier: An identity whose pipeline requests an audience that is not listed, or whose subject pattern matches every repository (repo:*), stops authenticating after the upgrade. See the 3.23.0 changelog.

Permission Denied

If API calls return permission errors:
  1. Verify the Workload Identity has the GitOps Service Agent role assigned.
  2. Check that the Workload Identity is a member of the target project.

Debug Token Claims

To inspect the OIDC token claims, decode the JWT:
This shows the token’s claims. Bytebase checks iss, aud, and sub against the identity’s settings; see Configuration.