mirror of
https://github.com/hashicorp/vault-action.git
synced 2025-11-09 16:16:55 +00:00
add more comments and docs
This commit is contained in:
parent
10ed4392a6
commit
c3509cc095
5 changed files with 24 additions and 23 deletions
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
|
|
@ -160,12 +160,9 @@ jobs:
|
|||
url: http://localhost:8200
|
||||
token: testtoken
|
||||
secrets: |
|
||||
secret/data/test-json-string jsonString ;
|
||||
secret/data/test-json-string jsonString | JSON_STRING ;
|
||||
|
||||
- name: Test Vault Action (verify JSON string format)
|
||||
run: |
|
||||
echo "${{ steps.import-secrets.outputs.jsonString }}" > secrets.json
|
||||
echo "${{ env.JSON_STRING }}" > secrets.json
|
||||
cat secrets.json
|
||||
# we should be able to parse the output as JSON
|
||||
jq -c . < secrets.json
|
||||
|
|
|
|||
4
.github/workflows/local-test.yaml
vendored
4
.github/workflows/local-test.yaml
vendored
|
|
@ -38,7 +38,9 @@ jobs:
|
|||
|
||||
- name: Import Secrets
|
||||
id: import-secrets
|
||||
# use the local changes
|
||||
uses: ./
|
||||
# run against a specific version of vault-action
|
||||
# uses: hashicorp/vault-action@v2.1.2
|
||||
with:
|
||||
url: http://localhost:8200
|
||||
|
|
@ -52,7 +54,7 @@ jobs:
|
|||
touch secrets.json
|
||||
echo "${{ steps.import-secrets.outputs.jsonString }}" >> secrets.json
|
||||
|
||||
- name: Check json file
|
||||
- name: Check json file format
|
||||
run: |
|
||||
echo
|
||||
cat secrets.json
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -1,3 +1,3 @@
|
|||
.PHONY: local-test
|
||||
local-test:
|
||||
docker compose down && docker-compose up -d vault && act workflow_dispatch -j local-test
|
||||
docker compose down; docker-compose up -d vault && act workflow_dispatch -j local-test
|
||||
|
|
|
|||
30
README.md
30
README.md
|
|
@ -547,24 +547,22 @@ $ npm run test:integration:basic # Choose one of: basic, enterprise, e2e, e2e-tl
|
|||
### Running the action locally
|
||||
|
||||
You can use the [act](https://github.com/nektos/act) command to test your
|
||||
changes locally if desired. Unfortunately it is not currently possible to use
|
||||
uncommitted local changes for a shared workfow. You will still need to push the
|
||||
changes you would like to validate beforehand. Even if a commit is necessary,
|
||||
this is still a more detailed and faster feedback loop than waiting for the
|
||||
action to be executed by Github in a different repository.
|
||||
changes locally.
|
||||
|
||||
Push your changes into a feature branch.
|
||||
```sh
|
||||
$ git checkout -b my-feature-branch
|
||||
$ git commit -m "testing new changes"
|
||||
$ git push
|
||||
```
|
||||
Edit the ./.github/workflows/local-test.yaml file and add any steps necessary
|
||||
to test your changes. You may have to additionally edit the Vault url, token
|
||||
and secret path if you are not using one of the provided containerized
|
||||
instances. The `local-test` job will call the ./integrationTests/e2e/setup.js
|
||||
script to bootstrap your local Vault instance with secrets.
|
||||
|
||||
Edit the ./.github/workflows/local-test.yaml file to use your new feature
|
||||
branch. You may have to additionally edit the vault url, token and secret path
|
||||
if you are not using one of the provided containerized instance. Run your
|
||||
feature branch locally.
|
||||
Run your feature branch locally:
|
||||
|
||||
```sh
|
||||
$ act workflow_dispatch -j local-test
|
||||
act workflow_dispatch -j local-test
|
||||
```
|
||||
|
||||
Or use the provided make target which will also spin up a Vault container:
|
||||
|
||||
```sh
|
||||
make local-test
|
||||
```
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ async function selectData(data, selector) {
|
|||
if (isJSON(d)) {
|
||||
// If we already have JSON we will not "stringify" it yet so that we
|
||||
// don't end up calling JSON.parse. This would break the secrets that
|
||||
// are stored as json. See: https://github.com/hashicorp/vault-action/issues/194
|
||||
// are stored as JSON. See: https://github.com/hashicorp/vault-action/issues/194
|
||||
result = d;
|
||||
} else {
|
||||
result = JSON.stringify(d);
|
||||
|
|
@ -106,6 +106,10 @@ async function selectData(data, selector) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* isJSON returns true if str parses as valid JSON
|
||||
* @param {string} str
|
||||
*/
|
||||
function isJSON(str) {
|
||||
if (typeof str !== "string"){
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue