Skip to content

feat(core): use the stored credential, deprecate GITHUB_TOKEN - #1807

Draft
sileht wants to merge 1 commit into
devs/sileht/mrgfy-8703-cli-auth-commands/mergify-auth-login-logout-status--b0b7d166from
devs/sileht/mrgfy-8703-cli-auth-commands/use-stored-credential-deprecate-github-token--ca890065
Draft

feat(core): use the stored credential, deprecate GITHUB_TOKEN#1807
sileht wants to merge 1 commit into
devs/sileht/mrgfy-8703-cli-auth-commands/mergify-auth-login-logout-status--b0b7d166from
devs/sileht/mrgfy-8703-cli-auth-commands/use-stored-credential-deprecate-github-token--ca890065

Conversation

@sileht

@sileht sileht commented Sep 4, 2026

Copy link
Copy Markdown
Member

mergify auth login stored a credential that nothing read. Now the
Mergify API chain reads it:

--token -> MERGIFY_TOKEN -> the stored credential -> GITHUB_TOKEN -> gh auth token

The stored credential sits above the two GitHub fallbacks because a
GITHUB_TOKEN left in a shell must not silently override a login the
user performed, and below --token and MERGIFY_TOKEN so a CI job that
sets one keeps working unchanged. Neither of those two warns. The last
two do, once per process on stderr -- ci junit-process uploads a batch
per file, and a warning repeated per API call would bury the output it
is warning about.

stack is untouched. It sends GitHub the same chain it sent before,
warns about nothing, and never sees a Mergify-issued token: a GitHub
token is the only kind api.github.com accepts, so deprecating it there
would be nonsense.

mergify ci is the other exception, and the reason the resolver takes
an Audience. Those routes are enable_auth_methods("ci_application_key")
server-side and refuse a user credential by design, because a CI runner
holds an organization key rather than somebody's personal login. So they
never get the stored credential -- offering one would replace a legible
"set MERGIFY_TOKEN" failure with an authentication error -- and both
their deprecation warning and their no-credential error name an
application key instead of mergify auth login, which would be a dead
end there. tests, queue, freeze, events and config simulate do
accept a user credential and get the full chain.

Two smaller consequences:

  • CommandContext::resolve now resolves the API URL before the token,
    because the credential is stored per API URL.
  • auth login and auth status both say when MERGIFY_TOKEN is set.
    Without that line "logged in" answers a question the user did not
    ask: what commands actually send is the environment variable. Both
    belong here rather than with the commands themselves, because the
    sentence only becomes true once this commit makes something read the
    stored credential -- and login is the moment somebody is watching,
    which status is not.

A machine with no configuration directory, or a store that cannot be
read, is a step of the chain that does not apply rather than a refusal
to authenticate -- both fall through with a debug line.

README, the five skills and the ten --token help strings that
documented the old chain are updated in the same commit: a user who
sees the deprecation warning and runs mergify queue --help to check
must not be told GITHUB_TOKEN is fine and the stored credential does
not exist.

Fixes MRGFY-8703

Depends-On: #1806

@sileht

sileht commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 refactor(core): split Mergify and GitHub token resolution #1802
2 feat(core): store the Mergify credential in the OS keychain #1803
3 feat(core): let a caller read an endpoint's rejection body #1804
4 feat(auth): the device authorization grant, client side #1805
5 feat(cli): mergify auth login, logout and status #1806
6 feat(core): use the stored credential, deprecate GITHUB_TOKEN #1807 👈
7 fix(core): never send a Mergify user token to GitHub #1808

@mergify

mergify Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 4 of 7 protections blocking · waiting on 👀 reviews, 🤖 CI and ⛓️ dependency

Protection Waiting on
🔴 ⛓️ Depends-On Requirements ⛓️ dependency
🔴 🤖 Continuous Integration 🤖 CI
🔴 👀 Review Requirements 👀 reviews
🔴 🔎 Reviews 👀 reviews
🟢 Enforce conventional commit
🟢 📕 PR description
🟢 🚦 Auto-queue

🔴 ⛓️ Depends-On Requirements

Waiting for

This rule is failing.

Requirement based on the presence of Depends-On in the body of the pull request

🔴 🤖 Continuous Integration

Waiting for

  • check-success=ci-gate
This rule is failing.
  • all of:
    • check-success=ci-gate

🔴 👀 Review Requirements

Waiting for

  • #approved-reviews-by>=2
This rule is failing.
  • any of:
    • #approved-reviews-by>=2
    • author = dependabot[bot]
    • author = mergify-ci-bot
    • author = renovate[bot]

🔴 🔎 Reviews

Waiting for

  • #review-requested = 0
This rule is failing.
  • #review-requested = 0
  • #changes-requested-reviews-by = 0
  • #review-threads-unresolved = 0

Show 3 satisfied protections

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|internal|docs|style|refactor|perf|test|build|ci|chore|revert|ui)(?:\(.+\))?!?:

🟢 📕 PR description

  • body ~= (?ms:.{48,})

🟢 🚦 Auto-queue

When all merge protections are satisfied, this pull request will be queued automatically.

@mergify
mergify Bot requested a review from a team September 4, 2026 23:27
`mergify auth login` stored a credential that nothing read. Now the
Mergify API chain reads it:

    --token -> MERGIFY_TOKEN -> the stored credential -> GITHUB_TOKEN -> gh auth token

The stored credential sits above the two GitHub fallbacks because a
`GITHUB_TOKEN` left in a shell must not silently override a login the
user performed, and below `--token` and `MERGIFY_TOKEN` so a CI job that
sets one keeps working unchanged. Neither of those two warns. The last
two do, once per process on stderr -- `ci junit-process` uploads a batch
per file, and a warning repeated per API call would bury the output it
is warning about.

`stack` is untouched. It sends GitHub the same chain it sent before,
warns about nothing, and never sees a Mergify-issued token: a GitHub
token is the only kind api.github.com accepts, so deprecating it there
would be nonsense.

`mergify ci` is the other exception, and the reason the resolver takes
an `Audience`. Those routes are `enable_auth_methods("ci_application_key")`
server-side and refuse a user credential by design, because a CI runner
holds an organization key rather than somebody's personal login. So they
never get the stored credential -- offering one would replace a legible
"set MERGIFY_TOKEN" failure with an authentication error -- and both
their deprecation warning and their no-credential error name an
application key instead of `mergify auth login`, which would be a dead
end there. `tests`, `queue`, `freeze`, `events` and `config simulate` do
accept a user credential and get the full chain.

Two smaller consequences:

- `CommandContext::resolve` now resolves the API URL before the token,
  because the credential is stored per API URL.
- `auth login` and `auth status` both say when `MERGIFY_TOKEN` is set.
  Without that line "logged in" answers a question the user did not
  ask: what commands actually send is the environment variable. Both
  belong here rather than with the commands themselves, because the
  sentence only becomes true once this commit makes something read the
  stored credential -- and `login` is the moment somebody is watching,
  which `status` is not.

A machine with no configuration directory, or a store that cannot be
read, is a step of the chain that does not apply rather than a refusal
to authenticate -- both fall through with a debug line.

README, the five skills and the ten `--token` help strings that
documented the old chain are updated in the same commit: a user who
sees the deprecation warning and runs `mergify queue --help` to check
must not be told GITHUB_TOKEN is fine and the stored credential does
not exist.

Fixes MRGFY-8703

Change-Id: Ica8900657087d82b92025ad80334e4e0da7862dc
@sileht
sileht force-pushed the devs/sileht/mrgfy-8703-cli-auth-commands/use-stored-credential-deprecate-github-token--ca890065 branch from b78ede8 to 320f6ae Compare September 4, 2026 23:40
@sileht
sileht force-pushed the devs/sileht/mrgfy-8703-cli-auth-commands/mergify-auth-login-logout-status--b0b7d166 branch from 58321f1 to 4b9647a Compare September 4, 2026 23:40
@sileht

sileht commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

Revision history

# Type Changes Reason Date
1 initial b78ede8 2026-09-04 23:40 UTC
2 rebase b78ede8 → 320f6ae (rebase only) 2026-09-04 23:40 UTC

@mergify
mergify Bot had a problem deploying to Mergify Merge Protections September 4, 2026 23:41 Failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant