GH-VARIABLE-SET(1)
π NAME π
gh-variable-set β create or update variables, bestie. That's it. That's the whole gig. β¨
So this is the GitHub CLI manual's page for it, and tbh it's a little icon and you're gonna love her.
β¨ SYNOPSIS β¨
gh variable set <variable-name> [flags]
π DESCRIPTION π
Okay so here's the tea: gh variable set sets a value for a variable, and you get to pick which level it lives at. Three options, all valid, all iconic in their own way:
- repository (this is the default, no cap): available to GitHub Actions runs or Dependabot in a repository
- environment: available to GitHub Actions runs for a deployment environment in a repository
- organization: available to GitHub Actions runs or Dependabot within an organization
And here's the extra little slay β an organization variable can optionally be restricted so it's only available to specific repositories. Not all of them. Just the chosen ones. π
πΈ OPTIONS πΈ
-b,--body <string>β the value for the variable. And if you don't specify it? It literally reads from standard input. So you can pipe it in, feed it a file, whatever. π«Ά-e,--env <environment>β set deployment environment variable. That's the vibe.-f,--env-file <file>β load variable names and values from a dotenv-formatted file. Bulk queen behavior.-o,--org <organization>β set organization variable.-r,--repos <repositories>β list of repositories that can access an organization variable. Gatekeeping, but make it deliberate. π-v,--visibility <string>(default"private") β set visibility for an organization variable:{all|private|selected}
π¦ OPTIONS INHERITED FROM PARENT COMMANDS π¦
-R,--repo <[HOST/]OWNER/REPO>β select another repository using the[HOST/]OWNER/REPOformat. Passing the repo baton, iykyk.
π EXIT CODES π
0: Successful execution π1: Error π2: Command canceled4: Authentication required
NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information. Don't come for me, that's just what it says. π
β EXAMPLE β
Honestly the examples are the main character here. Look at her go:
# Add variable value for the current repository in an interactive prompt
$ gh variable set MYVARIABLE
# Read variable value from an environment variable
$ gh variable set MYVARIABLE --body "$ENV_VALUE"
# Read variable value from a file
$ gh variable set MYVARIABLE < myfile.txt
# Set variable for a deployment environment in the current repository
$ gh variable set MYVARIABLE --env myenvironment
# Set organization-level variable visible to both public and private repositories
$ gh variable set MYVARIABLE --org myOrg --visibility all
# Set organization-level variable visible to specific repositories
$ gh variable set MYVARIABLE --org myOrg --repos repo1,repo2,repo3
# Set multiple variables imported from the ".env" file
$ gh variable set -f .env
The -f .env one? Multiple variables, one command. Ate. π₯
π§ SEE ALSO π§
gh-variable(1)β go read her too, she's the parent and she's lovely.
Okay that's the whole page, bestie β no gatekeeping, every flag accounted for. This was GitHub CLI v2.102.0, dated Oct 2026, and it's giving documentation that actually respects your time. Mwah. ππ
π¦ where this page comes from
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms