github3_utils.secrets

Functions for setting and updating GitHub Actions secrets.

Classes:

PublicKey

typing.TypedDict representing the return type of get_public_key().

Functions:

build_secrets_url(repo)

Returns the URL via which secrets can be checked and set.

encrypt_secret(public_key, secret_value)

Encrypt a GitHub Actions secret.

get_public_key(repo)

Returns the public key used to encrypt secrets for the given repository.

get_secrets(repo)

Returns a list of secret names for the given repository.

set_secret(repo, secret_name, value, public_key)

Set the value of the given secret.

typeddict PublicKey[source]

typing.TypedDict representing the return type of get_public_key().

Required Keys
Optional Keys
  • ETag (str)

  • Last-Modified (str)

build_secrets_url(repo)[source]

Returns the URL via which secrets can be checked and set.

Parameters

repo (Repository) – The repository to check/set secrets for.

Return type

URL

encrypt_secret(public_key, secret_value)[source]

Encrypt a GitHub Actions secret.

Parameters
  • public_key (str)

  • secret_value (str)

If the key has been obtained with get_secrets() then public_key will be:

get_secrets(repo)['key']
Return type

str

get_public_key(repo)[source]

Returns the public key used to encrypt secrets for the given repository.

Parameters

repo (Repository) – The repository the secrets are to be set for.

Return type

PublicKey

get_secrets(repo)[source]

Returns a list of secret names for the given repository.

Parameters

repo (Repository)

Return type

List[str]

set_secret(repo, secret_name, value, public_key)[source]

Set the value of the given secret.

Parameters
Return type

Response