How to Set Action Secrets Programmatically
Last Updated:
Overview
This article describes how to set action secrets programmatically.
Applies To
- Actions
Solution
- Call the Patch Action API with the secret payload:
{
"secrets": [
{"name": "secret1", "value": "super-secret-1"},
{"name": "secret2", "value": "super-secret-2"},
]
}
If only some of the secrets have to be updated while preserving others, the secrets that need to be preserved must be in the payload without the value section.E.g., the value of secret1 is preserved, and secret2 is updated with a new secret:
{
"secrets": [
{"name": "secret1"},
{"name": "secret2", "value": "new-secret-for-secret-2"},
]
}
- Call the Deploy Action API to activate the changes.
NOTE: Updating the Action secrets from within Actions is not recommended.