5
0
Fork 0
mirror of https://github.com/hashicorp/vault-action.git synced 2025-11-07 07:06:56 +00:00
A GitHub Action that simplifies using HashiCorp Vault™ secrets as build variables.
Find a file
2019-09-20 16:59:05 -05:00
.github/workflows feat: rethink how key retrevial is structued and add e2e test 2019-09-20 16:59:05 -05:00
e2e feat: rethink how key retrevial is structued and add e2e test 2019-09-20 16:59:05 -05:00
.gitignore Initial commit 2019-09-20 12:33:19 -05:00
action.js feat: rethink how key retrevial is structued and add e2e test 2019-09-20 16:59:05 -05:00
action.test.js feat: rethink how key retrevial is structued and add e2e test 2019-09-20 16:59:05 -05:00
action.yml feat: add initial code logic 2019-09-20 15:09:58 -05:00
index.js feat: add initial code logic 2019-09-20 15:09:58 -05:00
jest.config.js feat: rethink how key retrevial is structued and add e2e test 2019-09-20 16:59:05 -05:00
jsconfig.json feat: add initial code logic 2019-09-20 15:09:58 -05:00
LICENSE Initial commit 2019-09-20 12:33:19 -05:00
package-lock.json feat: rethink how key retrevial is structued and add e2e test 2019-09-20 16:59:05 -05:00
package.json feat: rethink how key retrevial is structued and add e2e test 2019-09-20 16:59:05 -05:00
README.md feat: rethink how key retrevial is structued and add e2e test 2019-09-20 16:59:05 -05:00

vault-action

A helper action for retrieving vault secrets as env vars.

Example Usage

jobs:
    build:
        # ...
        steps:
            # ...
            - name: Import Secrets
              uses: richicoder1/vault-action
              with:
                vaultUrl: https://vault.mycompany.com
                vaultToken: ${{ secrets.VaultToken }}
                keys: |
                    ci/aws accessKey | AWS_ACCESS_KEY_ID ;
                    ci/aws secretKey | AWS_SECRET_ACCESS_KEY ;
                    ci/npm token | NPM_TOKEN                    
            # ...

Key Syntax

The keys parameter is multiple keys separated by the ; character.

Each key is comprised of the path of they key, and optionally a JSONPath expression and an output name.

{{ Key Path }} > {{ JSONPath Query }} | {{ Output Environment Variable Name }}

Simple Key

To retrieve a key npmToken from path ci that has value somelongtoken from vault you could do:

with:
    keys: ci npmToken

vault-action will automatically normalize the given data key, and output:

NPMTOKEN=somelongtoken

Set Environment Variable Name

However, if you want to set it to a specific environmental variable, say NPM_TOKEN, you could do this instead:

with:
    keys: ci npmToken | NPM_TOKEN

With that, vault-action will now use your requested name and output:

NPM_TOKEN=somelongtoken

Multiple Keys

This 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:
    keys: |
        ci/aws accessKey | AWS_ACCESS_KEY_ID ;
        ci/aws secretKey | AWS_SECRET_ACCESS_KEY        

Masking

This action uses Github Action's built in masking, so all variables will automatically be masked if printed to the console or to logs.