gh-variable-set(1)

gh-variable-set1

Create or update variables

Usage

gh variable set <variable-name> [flags]

Overview

Set a value for a variable on one of the following levels: - repository (default): 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

Organization variable can optionally be restricted to only be available to specific repositories.

Options

-b, --body <string>

The value for the variable (reads from standard input if not specified)

-e, --env <environment>

Set deployment environment variable

-f, --env-file <file>

Load variable names and values from a dotenv-formatted file

-o, --org <organization>

Set organization variable

-r, --repos <repositories>

List of repositories that can access an organization variable

-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/REPO format

Exit status

0: Successful execution

1: Error

2: Command canceled

4: Authentication required

NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information.

Examples

# 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

Releases

2 releases since Debian 13 (Trixie); the text changed 1 time.

  1. 13
  2. Arch

From github-cli 2.102.1-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.