Updated November 10, 2026

    Secrets migration: Bitbucket variables to GitHub OIDC, and the credentials you stop storing

    Bitbucket workspace variables are a translation task. GitHub OIDC federation turns the migration into a chance to delete whole classes of long-lived credentials. Here is the model we recommend for cutovers where OIDC is on the table.

    By Marcin Noczynski

    Update, November 2026. GitHub changed the default OIDC subject format: repositories created, renamed or transferred after 15 July 2026 get an immutable sub that carries the owner ID and repository ID (repo:OWNER@OWNER-ID/REPO@REPO-ID:...), and every repository a migration creates on GitHub falls under that rule (GitHub changelog, OIDC reference). The trust-policy examples below now use that format; the earlier name-only examples would not match a freshly migrated repository. We also corrected the Google Cloud attribute-condition placement, the wait-timer description and the list of SaaS providers, noted that Bitbucket Pipelines has OIDC of its own, and made the closing section specific about what the Shyftport platform does with Bitbucket variables: it inventories names, never values. In this round we corrected what each cloud provider records for a federated token exchange (FAQ and audit section), stated which GitHub plans offer required reviewers and wait timers on private repositories, and removed shares that were presented as audit results.

    Bitbucket Pipelines handles deployment credentials through variables: a user with Admin on the repository (or the workspace) adds an AWS_SECRET_ACCESS_KEY, a GCP_SERVICE_ACCOUNT_JSON, or a DOCKER_REGISTRY_TOKEN as a secured variable, the pipeline reads it at runtime, the deploy proceeds. The model is simple and the credential typically lives for years. On GitHub Actions, the same deploy can be done the same way (store a secret, read it at runtime) but it can also be done without storing any long-lived credential at all, by federating the Actions runner's OIDC token to the cloud provider and letting it issue a short-lived credential per workflow run. The migration from Bitbucket to GitHub is the one moment the whole secret model is on the table.

    Many migration plans treat secrets as a translation task: list what is in Bitbucket, create matching entries in GitHub, done. That treatment ships the pre-existing debt (overly broad credentials, forgotten rotation, variables scoped to a workspace where they should have been per-repo, access keys for an IAM user nobody has reviewed in three years) directly into the new platform. OIDC federation is the lever that turns the migration from a translation task into a redesign that eliminates whole classes of credential at once, and the design decisions sit on top of a handful of specifics about trust policies, environment protection, and workflow scoping.

    This post is the migration shape we recommend for Bitbucket-to-GitHub cutovers where OIDC is on the table: what maps to OIDC, what stays as a stored secret, how to design the trust policy per cloud, and the pre-wave validation that keeps a surprise deployment-identity failure out of Monday morning.

    TL;DR

    1. Cloud deployment credentials go OIDC. On AWS, GCP, Azure, and most managed providers, Actions can assume a role without any stored secret.
    2. API tokens, SaaS credentials, and anything whose provider does not accept GitHub OIDC stay as stored secrets, scoped to the smallest possible blast radius (environment > repo > org).
    3. The trust policy on the cloud side is the migration deliverable, not the Actions workflow. An over-permissive trust that accepts any repo in the org is the anti-pattern to avoid.
    4. Non-prod and prod secrets get separate GitHub environments. Required reviewers on prod is the control the migration is the right moment to configure (on private repositories it needs GitHub Enterprise; see below).
    5. An audit of what is actually used precedes the migration. Expect some of the pipeline variables to be stale; the audit tells you how many.
    6. Rotation becomes a non-issue by default. The target state is zero long-lived cloud credentials in GitHub secrets, period.
    7. The pre-wave dry run deploys to a non-prod account using the real OIDC trust and the real workflow. No shortcuts.

    What Bitbucket actually stores

    Bitbucket Pipelines exposes credentials to pipelines through variables at three scopes:

    • Repository variables. Scoped to a single repository.
    • Deployment variables. Scoped to a Bitbucket Deployment environment (one of Test, Staging, Production, or a custom environment).
    • Workspace variables. Scoped to the whole workspace and visible to every pipeline in every repository.

    Each can be marked "secured" (not shown in logs) and used as $VAR in bitbucket-pipelines.yml. The access control is simple to describe and often loose in practice: anyone with Write on the repository can push a pipeline that references any variable the pipeline sees, including workspace-wide ones. Secured variables are not exfiltrated into logs, but a malicious or careless pipeline can still send them anywhere else at runtime.

    Bitbucket Pipelines also has OIDC of its own: a step with oidc: true receives a BITBUCKET_STEP_OIDC_TOKEN it can exchange with AWS, GCP or Vault. A workspace that already uses it is ahead on the model, but the trust does not carry over: the cloud side is bound to Bitbucket's issuer and claims, so every trust policy is rebuilt for GitHub's issuer and subject format during the migration.

    A pattern to look for first is a single workspace-wide AWS_ACCESS_KEY_ID plus AWS_SECRET_ACCESS_KEY for an IAM user with Administrator or near-Administrator privileges, created years ago, used by dozens of pipelines, and rotated the day someone finally remembers (or the day a departing engineer's access review surfaces it). Where it exists, that credential is the migration's primary redesign target.

    What GitHub Actions offers instead

    GitHub Actions has two independent mechanisms, and the migration uses both.

    Stored secrets at three scopes. Organization, repository, and environment. Visible to workflows that reference them; the environment scope adds protection rules, including required reviewers before a job accesses the environment's secrets.

    OIDC token issuance per workflow run. Actions issues a signed JWT identifying the repository, the workflow, the ref, the environment, and other claims (run id, actor, the numeric repository and owner IDs). A cloud provider configured to trust token.actions.githubusercontent.com can validate that JWT and mint short-lived credentials against a specific role or workload identity: AWS STS AssumeRoleWithWebIdentity, GCP Workload Identity Federation, Azure federated identity credentials, HashiCorp Vault JWT auth. The credential is minted for the duration of the job, never stored on GitHub's side, and the trust policy on the cloud side is what pins which repo and workflow can assume which role.

    The OIDC path has one property that matters most: there is no credential at rest to leak. The attack surface moves from "a secret stored in GitHub" to "a trust policy configured in the cloud provider," which is auditable, versionable, and has blast-radius controls the stored-secret model does not.

    OIDC trust-policy design per cloud

    The migration deliverable per cloud is the trust policy. The Actions-side wiring is a few lines of YAML and converges across all three major clouds; the policy design is where mistakes get made.

    AWS. Create an IAM OIDC identity provider for token.actions.githubusercontent.com. For each deployable application, create an IAM role whose trust policy restricts the OIDC sub claim to a specific repository and ref pattern: repo:acme@123456/payments@456789:ref:refs/heads/main for main-branch deploys, repo:acme@123456/payments@456789:environment:prod for environment-gated deploys. The numbers are the owner ID and the repository ID: since 15 July 2026 GitHub puts them into the default sub of every repository created, renamed or transferred after that date, which includes every repository a migration creates. Repositories created earlier keep the name-only form (repo:acme/payments:ref:refs/heads/main) until the organization or repository opts in, and GitHub Enterprise Server does not have the immutable format at all (OIDC reference). Read the IDs from the target repository after it exists, and write the policy for the format that repository actually emits. The anti-pattern to look for: a trust policy of repo:acme/*:* that accepts any repo in the org on any ref, which is functionally equivalent to pinning a long-lived IAM user to the entire org.

    GCP. Create a Workload Identity Pool with GitHub as a provider, map the OIDC claims to attributes (attribute.repository = assertion.repository, attribute.environment = assertion.environment), set the attribute condition on the provider (assertion.repository == 'acme/payments' && assertion.environment == 'prod', or the rename-proof assertion.repository_id, which Google recommends over names), and bind the service account only to the matching principal set. The anti-pattern mirrors AWS: a provider with no meaningful condition and a binding that trusts any repo in the pool.

    Azure. Add a federated identity credential to an app registration or a user-assigned managed identity, with the issuer https://token.actions.githubusercontent.com and the subject matching repo:acme@123456/payments@456789:environment:prod (the name-only repo:acme/payments:environment:prod for a repository still on the old format; Microsoft documents the move to immutable subjects). The anti-pattern is a wildcard subject or a shared app registration used across every workflow.

    The design we recommend as the default: one role (or service account, or managed identity) per deployable application per environment, with the trust policy pinned to the exact (repo, environment) pair. A workflow that touches two environments has two role ARNs; a workflow that is shared across repositories has a trust policy that lists each repository explicitly. This is more infrastructure to manage, and it is the point.

    Non-OIDC secrets: what stays and how to scope them

    Not everything goes OIDC. SaaS providers vary widely, and some third-party integrations still require a stored token. The scoping decision is the design question.

    A working classification for a Bitbucket-era secret inventory, used during the audit:

    Secret category Target state on GitHub Scope
    Cloud deployment creds (AWS, GCP, Azure) OIDC federation, no stored secret n/a
    Container registry push creds (ECR, GAR, ACR) OIDC-backed login where supported n/a
    SaaS API tokens with OIDC support (HashiCorp Cloud Platform, Snowflake, Vault) OIDC federation n/a
    SaaS API tokens without OIDC Stored secret Repo or env
    Third-party deploy tokens (Netlify, Vercel, etc.) Stored secret, short rotation Env (prod only)
    Internal API keys (private registries, internal services) Stored secret or OIDC via internal IdP Org or repo
    Stale, unused in 6 months Deleted during migration audit n/a

    How the inventory splits across these categories differs per workspace. The stale category is the reason the audit precedes the migration instead of following it.

    The scoping rules we hold to:

    • Organization-scoped only when genuinely shared. A single NPM_PUBLISH_TOKEN used by 30 repositories is a legitimate organization secret. A credential used by two repositories is not.
    • Repository-scoped is the default. Most non-OIDC secrets are specific to one application.
    • Environment-scoped for anything touching production. The environment scope exists specifically to let prod require human approval before a secret is accessible, and that control is the single most impactful one in the whole migration.

    Environment protection as the production gate

    For any repository that deploys somewhere, GitHub environments are the correct home for deployment secrets and the correct place to enforce human approval before a deploy. The three controls that matter on prod:

    • Required reviewers. A named team of humans must approve before a job targeting the environment runs. This turns a compromised PAT, a runaway workflow, or a malicious push into a stopped job rather than a fired-off deploy. We insist on this before wave one ships, not as a follow-up.
    • Deployment branches. Restrict which refs can deploy to the environment. prod deploys only from main or release/* is the pattern we recommend.
    • Wait timer. A configurable delay, from 1 minute up to 30 days, that holds the job after it is triggered and lets a change be cancelled if something looks wrong at the last minute.

    These controls depend on the GitHub plan. GitHub's reference says: "If you are on a GitHub Free, GitHub Pro, or GitHub Team plan, required reviewers are only available for public repositories", and the same sentence appears for wait timers. For private and internal repositories both therefore need GitHub Enterprise. Environment secrets and deployment branch rules are available for private repositories on GitHub Pro and GitHub Team as well. Check the plan of the target organization before the design assumes a human approval gate.

    The migration is the moment to actually configure these, not to defer. A deferred required-reviewer configuration easily becomes a "we will do it after cutover" that never happens. See also permissions redesign during GitHub migration for how environment protection fits the broader permission model.

    Rotation, audit, and governance after cutover

    The post-migration goal is a smaller, better-audited surface than Bitbucket had.

    Rotation disappears for OIDC-backed credentials. The role or service account itself has a trust policy, not a key. Rotating a credential is replaced by "rotate the trust policy if the signing-key infrastructure of the OIDC provider changes," which is a GitHub infrastructure problem, not a per-tenant one.

    Rotation stays for non-OIDC stored secrets, and gets scheduled. Each stored secret has an owner (a team, from the IDP-synced team map) and a rotation interval (90 days is a common policy; 30 for highest-risk credentials). The scheduling and reminders are automated against the GitHub API or an external secrets inventory; the team owning the secret rotates when the reminder fires.

    Audit lands in the cloud provider's log, not GitHub's. For OIDC-backed deploys, the authoritative record of what was deployed where is on the cloud side, and each provider records the token exchange differently. AWS CloudTrail logs AssumeRoleWithWebIdentity with the provider, the audience, the token subject (subjectFromWebIdentityToken), and the role session name, and nothing else from GitHub's token: set the role session name to include the run ID if you want to trace an AWS action back to a run. Google Cloud writes the Security Token Service exchange as a Data Access audit log, which you have to enable for the IAM and Security Token Service APIs, with the token subject in principalSubject. On Azure the exchange is a service principal sign-in in the Microsoft Entra sign-in logs, and the Azure Activity Log records the resource operations that follow. The default sub identifies the repository and the ref or environment, not the workflow run, so tying a cloud action to a run means carrying the run ID yourself or correlating by time. The GitHub Actions audit log says the workflow ran; the cloud audit log says what it did. The migration integrates both streams into the SIEM before wave one, not after. See also audit-trail continuity during platform migration for the broader audit workstream.

    Pre-wave validation, rollback, and common mistakes

    The validation that catches secret-model failures before they land in production is a deploy to a non-prod account using the real OIDC trust and the real workflow. Not a mocked trust policy, not a shortcut that uses a stored secret "for the dry run." The specific checks on the canary:

    • The OIDC trust policy accepts the expected (repo, environment) pair and rejects a workflow with a mismatched environment.
    • The required-reviewer rule on prod fires and blocks the deploy until a human approves.
    • The deploy-branches rule rejects a deploy from a non-release branch.
    • Every event, including the token exchange on the cloud side, lands in the audit stream (on Google Cloud this requires Data Access audit logs to be enabled).
    • A rollback deploy from the previous commit on main works, uses the same trust path, and audits identically.

    If any of those is red, the wave does not ship. The rollback plan for secrets specifically is "disable the trust policy and let the deploy fail obviously," not "keep the Bitbucket pipeline live as a backup," which is the shortcut that leaks the migration-era problems straight back into production.

    Three common mistakes:

    • Over-permissive OIDC trust. A trust policy of repo:acme/*:* or an unconditional workload-identity binding. The migration is the moment to pin each role to a specific (repo, environment) pair, and wave one is where that discipline is most at risk.
    • Stale secrets carried over. The migration translates every Bitbucket variable to a GitHub secret, including the ones that have not been used in six months. The audit is what prevents this; skipping the audit is what produces a post-migration secret inventory bigger than the one it replaced.
    • Prod and non-prod sharing credentials. A single stored secret used by both the staging deploy and the prod deploy, because that was the Bitbucket pattern. The GitHub migration is the moment to split those, with environment-level secrets and required reviewers on prod. Keeping them unified ships the Bitbucket risk model forward.

    Related reading: secrets and service connections migration covers the Azure DevOps angle on the same problem, and what breaks the first week after migration has a secrets-model section for a reason.

    How Shyftport handles this

    Secrets redesign is a workstream we open in parallel with repository migration, not after it. Our playbook starts with a pre-migration audit of every Bitbucket variable (what is it, who owns it, when was it last used, is there an OIDC path), produces a per-cloud trust-policy design before the first deploy workflow is rewritten, and lands environment-protected prod gates and non-OIDC scoping before wave one. The platform contributes the starting inventory: Shyftport's Bitbucket Cloud discovery lists pipeline variables by name, scope and secured flag, and its Excel export carries them on a Variables sheet. It never reads, stores or migrates a secret value, so every value that survives the audit is re-entered from its source of truth or replaced by an OIDC trust; the audit itself, the trust-policy design and the environment gates are engineering work we deliver as part of the migration programme. We treat the pre-wave canary deploy as a gate on cutover: no shortcut OIDC, no mocked trust policy. If your Bitbucket-to-GitHub migration is imminent and the secret model is still "we will do OIDC in phase two," talk to a Shyftport engineer and we will pressure-test the design against your estate.

    Sources

    1. About security hardening with OpenID Connect(accessed 2026-10-24)
    2. Configuring OpenID Connect in Amazon Web Services(accessed 2026-10-24)
    3. Configuring OpenID Connect in Google Cloud Platform(accessed 2026-10-24)
    4. Configuring OpenID Connect in Azure(accessed 2026-10-24)
    5. Using secrets in GitHub Actions(accessed 2026-10-24)
    6. OpenID Connect reference (GitHub Actions)(accessed 2026-11-10)
    7. Deployments and environments (GitHub Actions reference)(accessed 2026-11-10)
    8. Logging IAM and AWS STS API calls with AWS CloudTrail(accessed 2026-11-10)
    9. Example logs for Workload Identity Federation (Google Cloud)(accessed 2026-11-10)
    10. Service principal sign-in logs (Microsoft Entra)(accessed 2026-11-10)

    FAQ

    Can we migrate secrets one-to-one from Bitbucket and leave OIDC for later?
    You can, and it is a common proposal early in planning. We argue against it. The one-to-one translation ships Bitbucket's workspace-scoped, long-lived IAM users directly into GitHub secrets, where they tend to stay, because 'OIDC phase two' rarely gets prioritised after cutover. The migration is the one moment the deploy workflow is being rewritten anyway; adding OIDC to that rewrite is marginal effort and permanently removes the class of credential most likely to show up in a future breach report. The exception is a provider that does not accept GitHub OIDC, which does stay as a stored secret.
    Which cloud providers support OIDC federation with GitHub Actions?
    AWS (via IAM OIDC identity provider and AssumeRoleWithWebIdentity), GCP (via Workload Identity Federation and a workload identity pool), Azure (via federated identity credentials on an app registration or user-assigned managed identity), and HashiCorp Vault (via JWT auth) all have first-class support. Most managed Kubernetes platforms and container registries that sit on top of those clouds inherit the capability. SaaS providers vary: some (Snowflake, HashiCorp Cloud Platform service principals, PyPI publishing, npm) have added GitHub OIDC trust in the last few years; many still require stored API tokens. The migration audit identifies which secrets have an OIDC path and which do not.
    What about secrets that are not cloud credentials, like third-party API tokens?
    Stored secrets at the narrowest scope. GitHub Actions supports three scopes: organization, repository, and environment. The rule we hold to is organization-scoped only for secrets genuinely used by many repositories (a shared private registry token, for example), repository-scoped for the common case, and environment-scoped for anything that touches production. The environment scope adds the ability to require human approval before a job gets access, which is the single highest-leverage control available for prod-only secrets. We never leave non-prod and prod credentials in the same scope.
    How do we audit who actually used which secret after cutover?
    The authoritative trail is in the workflow run logs plus the cloud provider's own audit log, not GitHub's secret-use log (which does not exist at per-secret granularity). For OIDC-backed credentials, the cloud provider records each token exchange, but what the record carries differs. AWS CloudTrail logs the AssumeRoleWithWebIdentity call with the identity provider, the audience, the token subject, and the role session name; the other claims in GitHub's token, such as the workflow or the run ID, are not in the event, so put the run ID in the role session name. On Google Cloud the Security Token Service exchange is a Data Access audit log, which is off until you enable it for the IAM and Security Token Service APIs, and it records the token subject. On Azure the exchange is a service principal sign-in in the Microsoft Entra sign-in logs; the Azure Activity Log records the resource operations that follow, not the sign-in. The default GitHub subject names the repository and the ref or environment, not the run. For stored secrets, the Actions run log identifies which workflow and which run accessed the secret, correlated with the downstream API call in the provider's own log. The pre-cutover audit integration is doing both ends: Actions audit log into the SIEM, and the cloud audit stream enriched with the OIDC claim subject.

    Related reading