rulesync/Explanation/Rulesync authenticates to GitHub with GITHUB_TOKEN
Properties
- logseq-entity
- Logseq/Entity/Concept
Rulesync authenticates to GitHub with GITHUB_TOKEN
- Behaviour read from the jdx/mise docs at
bc1bdc54e(docs/dev-tools/github-tokens.md), and observed withrulesync 36.0.2,mise 2026.10.12andgh 2.102.0on macOS. Overview
rulesync installfetches rulesync sources, such as the skills incodekiln/logseq-encode-garden, through the GitHub contents API. It sends an authenticated request whenGITHUB_TOKENorGH_TOKENis set in its environment, and an anonymous request otherwise.- A
gh auth loginon macOS keeps the token in the Keychain. Rulesync never asksghfor it, so a shell that is signed in toghstill runs rulesync anonymously. - Anonymous requests share GitHub's limit of 60 per hour. One install of this garden's skills makes more than a hundred requests, so a single run spends the hour's allowance and the rest fail with
403and429errors:
Context
Why a git hook makes it visible
- lefthook runs
rulesync installafter every checkout and merge, so each step of a rebase spends more of the hour's allowance. A hook that exits non-zero stops the rebase.
- lefthook runs
Why
gh auth statussucceeds while rulesync failsWhat mise contributes
- mise has its own token lookup for its own GitHub calls. It reads
GITHUB_TOKEN, token files, theghhosts.ymlfile, and acredential_command. On macOS theghtoken sits in the Keychain, so mise needscredential_command = 'gh auth token --hostname "$MISE_CREDENTIAL_HOST"'to see it. See mise/Config/Setting/github.credential_command. - Those sources feed mise only. mise does not export the token to the programs it runs, and it does not read
GH_TOKENitself. credential_commandis global-only. A project'smise.tomlcannot set it.
- mise has its own token lookup for its own GitHub calls. It reads
Key Principles
Mechanism
- Three ways to put the token into rulesync's environment, from narrowest to widest:
- 1. A mise/Task/File that exports
GITHUB_TOKENfromgh auth tokenand then runsrulesync installandrulesync generate. The hook callsmise run <task>. One repository changes, and no token touches disk. This is the fixcodekiln/logseq-gardenuses, asrulesync:sync. - 2.
GH_TOKENexported from the shell profile, asexport GH_TOKEN=$(gh auth token). Every program started from that shell sees it, at the cost of oneghcall per shell. - 3. mise's native GitHub OAuth in the global mise config. With
github.oauth_client_idset to a GitHub App's client ID andmise token github --oauthrun once, mise exportsGITHUB_TOKENthroughmise activate,mise hook-env,mise envandmise exec. Every program run under mise reads it, including hooks that go throughmise xormise run. The token is a GitHub App user token, so it reaches only the repositories where the app is installed. It replaces aGITHUB_TOKENalready in the shell unlessgithub.oauth_export_envnames another variable.
- 1. A mise/Task/File that exports
- Three ways to put the token into rulesync's environment, from narrowest to widest:
Examples
- The file task,
mise-tasks/rulesync/sync:- bash
#!/usr/bin/env bash #MISE description="Install rulesync sources and regenerate tool config, authenticated with the gh login" set -euo pipefail if [[ -z "${GITHUB_TOKEN:-}${GH_TOKEN:-}" ]] && command -v gh >/dev/null; then GITHUB_TOKEN="$(gh auth token 2>/dev/null || true)" export GITHUB_TOKEN fi rulesync install rulesync generate
- The
lefthook.ymlentries, for bothpost-mergeandpost-checkout:
- The file task,
Misconceptions
- Behaviour read from the jdx/mise docs at