Skip to content

Commit

Permalink
Merge pull request #7 from 1Password/feature/output-secrets
Browse files Browse the repository at this point in the history
Enable using loaded secrets from step's output
  • Loading branch information
edif2008 authored Sep 2, 2021
2 parents e8da10d + 000522e commit fae9e58
Show file tree
Hide file tree
Showing 9 changed files with 2,441 additions and 22 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,35 @@ on: push
name: Run acceptance tests

jobs:
test:
test-output-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Launch 1Password Connect instance
env:
OP_CONNECT_CREDENTIALS: ${{ secrets.OP_CONNECT_CREDENTIALS }}
run: |
echo "$OP_CONNECT_CREDENTIALS" > 1password-credentials.json
docker-compose -f tests/fixtures/docker-compose.yml up -d && sleep 10
- name: Configure 1Password Connect
uses: ./configure # 1password/load-secrets-action/configure@<version>
with:
connect-host: http://localhost:8080
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load secrets
id: load_secrets
uses: ./ # 1password/load-secrets-action@<version>
env:
SECRET: op://acceptance-tests/test-secret/password
SECRET_IN_SECTION: op://acceptance-tests/test-secret/test-section/password
MULTILINE_SECRET: op://acceptance-tests/multiline-secret/notesPlain
- name: Assert test secret values
env:
SECRET: ${{ steps.load_secrets.outputs.SECRET }}
SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.SECRET_IN_SECTION }}
MULTILINE_SECRET: ${{ steps.load_secrets.outputs.MULTILINE_SECRET }}
run: ./tests/assert-env-set.sh
test-export-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -19,6 +47,8 @@ jobs:
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load secrets
uses: ./ # 1password/load-secrets-action@<version>
with:
export-env: true
env:
SECRET: op://acceptance-tests/test-secret/password
SECRET_IN_SECTION: op://acceptance-tests/test-secret/test-section/password
Expand All @@ -31,7 +61,5 @@ jobs:
uses: ./ # 1password/load-secrets-action@<version>
with:
unset-previous: true
- name: Print environment variables with secrets removed
run: printenv
- name: Assert removed secrets
run: ./tests/assert-env-unset.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
11 changes: 5 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ inputs:
unset-previous:
description: Whether to unset environment variables populated by 1Password in earlier job steps
default: false
export-env:
description: Export the secrets as environment variables
default: false
runs:
using: composite
steps:
- run: |
export INPUT_UNSET_PREVIOUS=${{ inputs.unset-previous }}
${{ github.action_path }}/entrypoint.sh
shell: bash
using: 'node12'
main: 'dist/index.js'
Loading

0 comments on commit fae9e58

Please sign in to comment.