gh secret set MY_SECRET --env production --body 'supersecret'

Category: GitHub CLI

gh secret set MY_SECRET --env production --body 'supersecret'

Set an environment-scoped secret

Creates or updates MY_SECRET inside the production environment, and --body supplies the value non-interactively for scripting. Environment secrets are visible only to jobs referencing that environment. Prefer this over repo-wide secrets for deployment credentials.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.