Skip to content

UID2-6753: declare GH_MERGE_TOKEN as optional workflow_call secret#226

Merged
BehnamMozafari merged 2 commits intomainfrom
bmz-UID2-6753-add-gh-merge-token-secret
May 4, 2026
Merged

UID2-6753: declare GH_MERGE_TOKEN as optional workflow_call secret#226
BehnamMozafari merged 2 commits intomainfrom
bmz-UID2-6753-add-gh-merge-token-secret

Conversation

@BehnamMozafari
Copy link
Copy Markdown
Contributor

Summary

Declares GH_MERGE_TOKEN as an optional workflow_call.secrets entry on shared-publish-java-to-docker-versioned.yaml. Existing callers are unaffected; cross-organization callers can now pass the token explicitly.

Problem

The reusable workflow needs a PAT (GH_MERGE_TOKEN) to merge the version-bump PR back to the default branch when branch protection requires bypass. The expression

github_token: ${{ inputs.merge_environment != '' && secrets.GH_MERGE_TOKEN || '' }}

relies on the secret being available inside this workflow's secrets context.

When the caller is in the same organization (e.g. IABTechLab/uid2-core), secrets: inherit plus the called job's environment: ci-auto-merge correctly exposes the env-scoped secret to the called workflow, and commit_pr_and_merge receives the token (verified — see with: github_token: *** in any recent uid2-core release).

When the caller is in a different organization (e.g. UnifiedID2/uid2-snowflake), secrets: inherit does not propagate environment-scoped secrets to the called workflow's secrets context. The expression collapses to '', commit_pr_and_merge falls back to GITHUB_TOKEN, which has no bypass on the caller's PR-review ruleset, and the merge step fails with HTTP 405 "New changes require approval from someone other than the last pusher" — see the failure on UnifiedID2/uid2-snowflake#25202341348.

References:

  • Reusing workflowssecrets: inherit and the secrets: map on a uses: job.
  • actions/runner#1490 — environment-scoped secrets are not injected into cross-repo reusable workflow jobs.

Change

Add an optional secrets: declaration to workflow_call:

secrets:
  GH_MERGE_TOKEN:
    description: ...
    required: false

The existing two github_token: ${{ inputs.merge_environment != '' && secrets.GH_MERGE_TOKEN || '' }} references are unchanged.

Why this is backward compatible

  • Callers that use secrets: inherit continue to work exactly as before. Declaring a secret on workflow_call.secrets does not change inherit semantics.
  • Callers that pass nothing (no secrets: block at all) continue to work — the optional secret is empty, inputs.merge_environment is '' by default, and the action falls back to GITHUB_TOKEN. This matches today's behaviour for callers that don't opt into auto-merge.
  • Cross-organization callers can now opt into explicit pass-through:
    secrets:
      GH_MERGE_TOKEN: ${{ secrets.GH_MERGE_TOKEN }}
    This requires the caller's repo to have GH_MERGE_TOKEN accessible at repo or org level (a job that calls a reusable workflow cannot itself declare environment:, so env-scoped-only secrets are not readable in the caller's evaluation context).

Follow-up

A companion PR will switch UnifiedID2/uid2-snowflake/.github/workflows/publish-docker.yaml to the explicit pass form, paired with the org-level GH_MERGE_TOKEN recently added in uid2-okta-configuration (commit 2714fb1).

Test plan

  • Merge, confirm v3 floating tag advances.
  • Trigger IABTechLab/uid2-core release on main — should still succeed via secrets: inherit (no caller change).
  • After companion snowflake PR merges, trigger UnifiedID2/uid2-snowflake/publish-docker.yaml on main — should succeed; commit_pr_and_merge step should show github_token: *** in its inputs.

BehnamMozafari and others added 2 commits May 4, 2026 10:33
Allows callers to pass the merge PAT explicitly via
`secrets: { GH_MERGE_TOKEN: ${{ secrets.GH_MERGE_TOKEN }} }`, which is
the only path that works for cross-organization callers. The existing
`secrets: inherit` flow continues to work (the secret is inherited as
before for same-org/same-enterprise callers, and now for org-level
secrets cross-org as well).

Background: when called cross-organization (e.g. UnifiedID2/uid2-snowflake
calling IABTechLab/uid2-shared-actions), `secrets: inherit` does not
propagate environment-scoped secrets. See
actions/runner#1490.

The expression `secrets.GH_MERGE_TOKEN` inside this workflow is unchanged,
so behaviour is fully backward compatible: when the caller passes nothing
and the secret is not inherited, the value is empty and `commit_pr_and_merge`
falls back to GITHUB_TOKEN (current behaviour).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@BehnamMozafari BehnamMozafari self-assigned this May 4, 2026
@BehnamMozafari BehnamMozafari merged commit 6ea068b into main May 4, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants