This action replaces values preceded by SECRET_ in a given file. This is useful for replacing github secrets in an .env file.
Required The .env (or other) file where some values begin with SECRET_
DB_PWD=SECRET_DB_PASSWORD
SAMPLE_KEY=SECRET_SAMPLE_KEY
Required A JSON object containing the keys (without the SECRET_ prefix) and values that should be replaced if found within the file.
{
"DB_PASSWORD": "12345SecurePassword!",
"SAMPLE_KEY": "mySecretKey123abc"
}
- name: Replace secrets in .env
uses: codeurs/secrets-replace@v4
with:
file: "path/to/.env"
secrets: ${{ toJson(secrets) }}