You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
Export all secrets to env variables
v1
This action provides the following functionality for GitHub Actions users:
- Read Github secrets and export them as environment variables
- Optionally including, excluding and manipulating variables as needed before importing
Add the following action to your workflow:
- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
Note the secrets
key. It is mandatory so the action can read and export the secrets.
Basic:
steps:
- uses: actions/checkout@v3
- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
- run: echo "Value of MY_SECRET: $MY_SECRET"
Include or exclude secrets:
Exclude defined secret MY_SECRET
from list of secrets.
steps:
- uses: actions/checkout@v3
- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
exclude: MY_SECRET
# MY_SECRET is not export
Only include secret MY_SECRET
steps:
- uses: actions/checkout@v3
- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
include: MY_SECRET
- run: echo "Value of MY_SECRET: $MY_SECRET"
NOTE: If specified secret does not exist, it is ignored.
Add a prefix:
Adds a prefix to all exported secrets.
steps:
- uses: actions/checkout@v3
- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
prefix: PREFIXED_
- run: echo "Value of PREFIXED_MY_SECRET: $PREFIXED_MY_SECRET"
Convert:
Converts all exported secrets according to a template.
Available: lower, upper, camel, constant, pascal, snake
.
steps:
- uses: actions/checkout@v3
- uses: oNaiPs/secrets-to-env-action@v1
with:
secrets: ${{ toJSON(secrets) }}
convert: lower
- run: echo "Value of my_secret: $my_secret"
The scripts and documentation in this project are released under the MIT License
Contributions are welcome!