gitea.cli.actions.secret.set
set
Set an Actions secret of a repository, an organization or the account.
One command for creating and for replacing, because Gitea has one endpoint for
both: it answers 201 when the secret was new and 204 when it replaced one.
Both are success, so a script that only needs the secret to hold a value does not
have to look first, and one that cares reads the status code out of the envelope's
metadata.
--data - reads the value from stdin, which is the spelling to use anywhere the
value matters: a value passed on the command line is visible in the shell history
and in the process list of the machine it runs on, and neither is a place for a
secret. Exactly one trailing newline is stripped, so printf %s and echo both
send what they look like they send.
Which scope is asked for follows the usual convention: --owner with
--repository for a repository's secret, --owner alone for an organization's,
and neither for one of the authenticated account's.
Functions:
gitea.cli.actions.secret.set.read_secret_data
Read the value to store, from the option or from stdin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
The value passed as --data, or |
required |
Returns:
| Type | Description |
|---|---|
str
|
The value to store. When it came from stdin, one trailing newline is |
str
|
stripped - the one the shell adds - so that |
str
|
stores what it looks like it stores. A value that really ends in a |
str
|
newline is sent with a second one. |
Raises:
| Type | Description |
|---|---|
CommandError
|
If stdin was asked for and carried nothing, which is what a command substitution that produced nothing looks like. |
Source code in src/gitea/cli/actions/secret/set.py
gitea.cli.actions.secret.set.set_secret_command
set_secret_command(
ctx: Context,
secret_name: Annotated[
str, Option("--secret-name", help=SECRET_NAME_HELP)
],
data: Annotated[str, Option("--data", help=DATA_HELP)],
owner: Annotated[
str | None, Option("--owner", help=OWNER_SCOPE_HELP)
] = None,
repository: Annotated[
str | None,
Option("--repository", help=REPOSITORY_SCOPE_HELP),
] = None,
description: Annotated[
str | None,
Option(
"--description",
help="What the secret is for, shown alongside it in the web UI. Omitting it leaves the existing one.",
),
] = None,
account_name: Annotated[
str | None,
Option(
"--account-name",
help="Name of the account to use for authentication.",
),
] = None,
token: Annotated[
str | None,
Option(
"--token",
help="Token for authentication. If not provided, the token from the specified account will be used.",
),
] = None,
base_url: Annotated[
str | None,
Option(
"--base-url",
help="Base URL of the Gitea platform. If not provided, the base URL from the specified account will be used.",
),
] = None,
) -> None
Set an Actions secret, creating it or replacing its value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
Context
|
The Typer context. |
required |
secret_name
|
Annotated[str, Option('--secret-name', help=SECRET_NAME_HELP)]
|
The name of the secret. |
required |
data
|
Annotated[str, Option('--data', help=DATA_HELP)]
|
The value to store, or |
required |
owner
|
Annotated[str | None, Option('--owner', help=OWNER_SCOPE_HELP)]
|
The owner of the repository, or the organization itself. |
None
|
repository
|
Annotated[str | None, Option('--repository', help=REPOSITORY_SCOPE_HELP)]
|
The name of the repository, to narrow the owner to one of its repositories. |
None
|
description
|
Annotated[str | None, Option('--description', help='What the secret is for, shown alongside it in the web UI. Omitting it leaves the existing one.')]
|
What the secret is for. |
None
|
account_name
|
Annotated[str | None, Option('--account-name', help='Name of the account to use for authentication.')]
|
Name of the account to use for authentication. |
None
|
token
|
Annotated[str | None, Option('--token', help='Token for authentication. If not provided, the token from the specified account will be used.')]
|
Token for authentication. |
None
|
base_url
|
Annotated[str | None, Option('--base-url', help='Base URL of the Gitea platform. If not provided, the base URL from the specified account will be used.')]
|
Base URL of the Gitea platform. |
None
|
Source code in src/gitea/cli/actions/secret/set.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |