diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9447f59..66e762b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,11 +12,14 @@ jobs: 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 + with: + connect-host: http://localhost:8080 + connect-token: ${{ secrets.OP_CONNECT_TOKEN }} - name: Load secrets uses: ./ env: - OP_CONNECT_HOST: http://localhost:8080 - OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }} SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password SECRET_IN_SECTION: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/test-section/password MULTILINE_SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/ghtz3jvcc6dqmzc53d3r3eskge/notesPlain @@ -35,8 +38,6 @@ jobs: - name: Load secret again uses: ./ env: - OP_CONNECT_HOST: http://localhost:8080 - OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }} SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password SECRET_IN_SECTION: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/test-section/password MULTILINE_SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/ghtz3jvcc6dqmzc53d3r3eskge/notesPlain diff --git a/configure/action.yml b/configure/action.yml new file mode 100644 index 0000000..e9a98e7 --- /dev/null +++ b/configure/action.yml @@ -0,0 +1,14 @@ +name: configure-action +inputs: + connect-host: + description: Your 1Password Connect instance URL + connect-token: + description: Token to authenticate to your 1Password Connect instance +runs: + using: composite + steps: + - run: | + export INPUT_CONNECT_HOST=${{ inputs.connect-host }} + export INPUT_CONNECT_TOKEN=${{ inputs.connect-token }} + ${{ github.action_path }}/entrypoint.sh + shell: bash diff --git a/configure/entrypoint.sh b/configure/entrypoint.sh new file mode 100755 index 0000000..97d0853 --- /dev/null +++ b/configure/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -e + +# Capture Connect configuration in $GITHUB_ENV, giving (optional) inputs +# precendence over OP_CONNECT_* environment variables. + +OP_CONNECT_HOST=${INPUT_CONNECT_HOST:-$OP_CONNECT_HOST} +if [ -n "$OP_CONNECT_HOST" ]; then + echo "OP_CONNECT_HOST=$OP_CONNECT_HOST" >> $GITHUB_ENV +fi + +OP_CONNECT_TOKEN=${INPUT_CONNECT_TOKEN:-$OP_CONNECT_TOKEN} +if [ -n "$OP_CONNECT_TOKEN" ]; then + echo "OP_CONNECT_TOKEN=$OP_CONNECT_TOKEN" >> $GITHUB_ENV +fi