← 返回命令列表

Linux command

gh-variable 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

List variables

gh variable list

Set a variable

gh variable set [name] -b "[value]"

Set from file

gh variable set [name] < [file]

Delete a variable

gh variable delete [name]

Get a variable value

gh variable get [name]

Set organization variable

gh variable set [name] -o [org] -b "[value]"

Set environment variable

gh variable set [name] -e [environment] -b "[value]"

List variables as JSON

gh variable list --json name,value

说明

gh variable manages GitHub Actions configuration variables for storing non-sensitive workflow data. Unlike secrets, variables are not encrypted and their values can be retrieved, making them suitable for configuration settings, feature flags, and environment names. Variables can be scoped to repositories, organizations, or specific deployment environments. They are accessible in workflows via the vars context (e.g., `vars.VARIABLE_NAME`). They are ideal for API endpoints, build configurations, and other non-secret parameters.

参数

-b, --body _value_
Variable value.
-R, --repo _owner/repo_
Select a repository.
-o, --org _name_
Set or list variables for an organization.
-e, --env _name_
Set or list variables for an environment.
-v, --visibility _scope_
Set visibility for an organization variable: all, private, or selected.
--json _fields_
Output JSON with the specified fields.
-q, --jq _expression_
Filter JSON output using a jq expression.

FAQ

What is the gh-variable command used for?

gh variable manages GitHub Actions configuration variables for storing non-sensitive workflow data. Unlike secrets, variables are not encrypted and their values can be retrieved, making them suitable for configuration settings, feature flags, and environment names. Variables can be scoped to repositories, organizations, or specific deployment environments. They are accessible in workflows via the vars context (e.g., `vars.VARIABLE_NAME`). They are ideal for API endpoints, build configurations, and other non-secret parameters.

How do I run a basic gh-variable example?

Run `gh variable list` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -b, --body _value_ do in gh-variable?

Variable value.