gh variable set MY_VAR --env production --body 'https://api.example.com'

Category: GitHub CLI

gh variable set MY_VAR --env production --body 'https://api.example.com'

Set an environment-scoped variable

Creates or updates MY_VAR for the production environment with the given plaintext value. Unlike secrets, variable values appear in plain in workflow logs when referenced. Environment variables override repo-level ones of the same name.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.