Secretos del repositorio de Codespaces
Usa la API de REST para administrar los secretos para repositorios a los que el usuario tiene acceso en un codespace.
Acerca de los secretos de repositorio de Codespaces
Puedes crear, ver y eliminar secretos (como los tokens de acceso de los servicios en la nube) para los repositorios a los que el usuario tenga acceso. Estos secretos se hacen disponibles para el codespace en el tiempo de ejecución. Para obtener más información, vea «Administrar secretos para sus codespaces».
List repository secrets
Lists all development environment secrets available in a repository without revealing their encrypted values. You must authenticate using an access token with the repo
scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets
repository permission to use this endpoint.
Parámetros para "List repository secrets"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
repo string RequeridoThe name of the repository without the |
Nombre, Tipo, Descripción |
---|
per_page integer The number of results per page (max 100). Valor predeterminado: |
page integer Page number of the results to fetch. Valor predeterminado: |
Códigos de estado de respuesta HTTP para "List repository secrets"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "List repository secrets"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/codespaces/secrets
Response
Status: 200
{
"total_count": 2,
"secrets": [
{
"name": "GH_TOKEN",
"created_at": "2019-08-10T14:59:22Z",
"updated_at": "2020-01-10T14:59:22Z",
"visibility": "all"
},
{
"name": "GIST_ID",
"created_at": "2020-01-10T10:59:22Z",
"updated_at": "2020-01-11T11:59:22Z",
"visibility": "all"
}
]
}
Get a repository public key
Gets your public key, which you need to encrypt secrets. You need to encrypt a secret before you can create or update secrets. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo
scope. GitHub Apps must have write access to the codespaces_secrets
repository permission to use this endpoint.
Parámetros para "Get a repository public key"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
repo string RequeridoThe name of the repository without the |
Códigos de estado de respuesta HTTP para "Get a repository public key"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "Get a repository public key"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/codespaces/secrets/public-key
Response
Status: 200
{
"key_id": "012345678912345678",
"key": "2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234"
}
Get a repository secret
Gets a single repository development environment secret without revealing its encrypted value. You must authenticate using an access token with the repo
scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets
repository permission to use this endpoint.
Parámetros para "Get a repository secret"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
repo string RequeridoThe name of the repository without the |
secret_name string RequeridoThe name of the secret. |
Códigos de estado de respuesta HTTP para "Get a repository secret"
status code | Descripción |
---|---|
200 | OK |
Ejemplos de código para "Get a repository secret"
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME
Response
Status: 200
{
"name": "GH_TOKEN",
"created_at": "2019-08-10T14:59:22Z",
"updated_at": "2020-01-10T14:59:22Z",
"visibility": "all"
}
Create or update a repository secret
Creates or updates a repository development environment secret with an encrypted value. Encrypt your secret using LibSodium. For more information, see "Encrypting secrets for the REST API."
You must authenticate using an access
token with the repo
scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets
repository permission to use this endpoint.
Parámetros para "Create or update a repository secret"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
repo string RequeridoThe name of the repository without the |
secret_name string RequeridoThe name of the secret. |
Nombre, Tipo, Descripción |
---|
encrypted_value string Value for your secret, encrypted with LibSodium using the public key retrieved from the Get a repository public key endpoint. |
key_id string ID of the key you used to encrypt the secret. |
Códigos de estado de respuesta HTTP para "Create or update a repository secret"
status code | Descripción |
---|---|
201 | Response when creating a secret |
204 | Response when updating a secret |
Ejemplos de código para "Create or update a repository secret"
curl -L \
-X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME \
-d '{"encrypted_value":"c2VjcmV0","key_id":"012345678912345678"}'
Response when creating a secret
Status: 201
Delete a repository secret
Deletes a development environment secret in a repository using the secret name. You must authenticate using an access token with the repo
scope to use this endpoint. GitHub Apps must have write access to the codespaces_secrets
repository permission to use this endpoint.
Parámetros para "Delete a repository secret"
Nombre, Tipo, Descripción |
---|
accept string Setting to |
Nombre, Tipo, Descripción |
---|
owner string RequeridoThe account owner of the repository. The name is not case sensitive. |
repo string RequeridoThe name of the repository without the |
secret_name string RequeridoThe name of the secret. |
Códigos de estado de respuesta HTTP para "Delete a repository secret"
status code | Descripción |
---|---|
204 | No Content |
Ejemplos de código para "Delete a repository secret"
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/codespaces/secrets/SECRET_NAME
Response
Status: 204