Skip to main content

variables

Creates, updates, deletes, gets or lists a variables resource.

Overview

Namevariables
TypeResource
Idgithub.actions.variables

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
namestringThe name of the variable. (example: USERNAME)
created_atstring (date-time)The date and time at which the variable was created, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ. (example: 2019-01-24T22:45:36.000Z)
updated_atstring (date-time)The date and time at which the variable was last updated, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ. (example: 2019-01-24T22:45:36.000Z)
valuestringThe value of the variable. (example: octocat)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_environment_variableselectowner, repo, environment_name, nameGets a specific variable in an environment.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.
get_repo_variableselectowner, repo, nameGets a specific variable in a repository.

The authenticated user must have collaborator access to the repository to use this endpoint.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
list_environment_variablesselectowner, repo, environment_nameper_page, pageLists all environment variables.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
get_org_variableselectorg, nameGets a specific variable in an organization.

The authenticated user must have collaborator access to a repository to create, update, or read variables.

OAuth tokens and personal access tokens (classic) need theadmin:org scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.
list_repo_variablesselectowner, repoper_page, pageLists all repository variables.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
list_org_variablesselectorgper_page, pageLists all organization variables.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint. If the repository is private, the repo scope is also required.
create_environment_variableinsertowner, repo, environment_name, name, valueCreate an environment variable that you can reference in a GitHub Actions workflow.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.
create_repo_variableinsertowner, repo, name, valueCreates a repository variable that you can reference in a GitHub Actions workflow.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.
create_org_variableinsertorg, name, value, visibilityCreates an organization variable that you can reference in a GitHub Actions workflow.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth tokens and personal access tokens (classic) need theadmin:org scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.
update_environment_variableupdateowner, repo, name, environment_nameUpdates an environment variable that you can reference in a GitHub Actions workflow.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
update_repo_variableupdateowner, repo, nameUpdates a repository variable that you can reference in a GitHub Actions workflow.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
update_org_variableupdateorg, nameUpdates an organization variable that you can reference in a GitHub Actions workflow.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth app tokens and personal access tokens (classic) need the admin:org scope to use this endpoint. If the repository is private, the repo scope is also required.
delete_environment_variabledeleteowner, repo, name, environment_nameDeletes an environment variable using the variable name.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.
delete_repo_variabledeleteowner, repo, nameDeletes a repository variable using the variable name.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.
delete_org_variabledeleteorg, nameDeletes an organization variable using the variable name.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth tokens and personal access tokens (classic) need theadmin:org scope to use this endpoint. If the repository is private, OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
environment_namestringThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
namestringThe name of the variable.
orgstringThe organization name. The name is not case sensitive.
ownerstringThe account owner of the repository. The name is not case sensitive.
repostringThe name of the repository without the .git extension. The name is not case sensitive.
pageintegerThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pageintegerThe number of results per page (max 30). For more information, see "Using pagination in the REST API."

SELECT examples

Gets a specific variable in an environment.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

SELECT
name,
created_at,
updated_at,
value
FROM github.actions.variables
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND environment_name = '{{ environment_name }}' -- required
AND name = '{{ name }}' -- required
;

INSERT examples

Create an environment variable that you can reference in a GitHub Actions workflow.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

INSERT INTO github.actions.variables (
name,
value,
owner,
repo,
environment_name
)
SELECT
'{{ name }}' /* required */,
'{{ value }}' /* required */,
'{{ owner }}',
'{{ repo }}',
'{{ environment_name }}'
;

UPDATE examples

Updates an environment variable that you can reference in a GitHub Actions workflow.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

UPDATE github.actions.variables
SET
name = '{{ name }}',
value = '{{ value }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND name = '{{ name }}' --required
AND environment_name = '{{ environment_name }}' --required;

DELETE examples

Deletes an environment variable using the variable name.

Authenticated users must have collaborator access to a repository to create, update, or read variables.

OAuth tokens and personal access tokens (classic) need the repo scope to use this endpoint.

DELETE FROM github.actions.variables
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND name = '{{ name }}' --required
AND environment_name = '{{ environment_name }}' --required
;