A helper action for pulling secrets from the Hashicorp Vault API.
jobs:
build:
# ...
steps:
# ...
- name: Import Secrets
uses: RichiCoder1/vault-action
with:
url: https://vault.mycompany.com:8200
token: ${{ secrets.VaultToken }}
skip_tls_verification: false
secrets: |
ci/aws accessKey | AWS_ACCESS_KEY_ID ;
ci/aws secretKey | AWS_SECRET_ACCESS_KEY ;
ci npm_token
# ...The secrets parameter is a set of multiple secret requests separated by the ; character.
Each secret request is comprised of the path and the key of the desired secret, and optionally the desired Env Var output name.
{{ Secret Path }} {{ Secret Key }} | {{ Output Environment Variable Name }}
To retrieve a key npmToken from path ci that has value somelongtoken from vault you could do:
with:
secrets: ci npmTokenvault-action will automatically normalize the given data key, and output:
NPMTOKEN=somelongtokenHowever, if you want to set it to a specific environmental variable, say NPM_TOKEN, you could do this instead:
with:
secrets: ci npmToken | NPM_TOKENWith that, vault-action will now use your requested name and output:
NPM_TOKEN=somelongtokenThis action can take multi-line input, so say you had your AWS keys stored in a path and wanted to retrieve both of them. You can do:
with:
secrets: |
ci/aws accessKey | AWS_ACCESS_KEY_ID ;
ci/aws secretKey | AWS_SECRET_ACCESS_KEYThis action could be use with namespace Vault Enterprise feature. You can specify namespace in request :
steps:
# ...
- name: Import Secrets
uses: RichiCoder1/vault-action
with:
url: https://vault-enterprise.mycompany.com:8200
token: ${{ secrets.VaultToken }}
namespace: ns1
secrets: |
ci/aws accessKey | AWS_ACCESS_KEY_ID ;
ci/aws secretKey | AWS_SECRET_ACCESS_KEY ;
ci npm_tokenThis action uses Github Action's built in masking, so all variables will automatically be masked if printed to the console or to logs.