Skip to content

Commit 0a7975f

Browse files
authored
Ensure that the action is backwards-compatible (#25)
Bring 2 changes that ensure that the GitHub Action is backwards compatible: - Append `http://` if the prefix is not provided in the `OP_CONNECT_HOST` (this is caused by the fact that `curl` guesses the protocol if not provided (https://linux.die.net/man/1/curl), which we missed when switching to using the 1Password CLI as the backend of the action) - Set the default of export-env to true, since that was the default behavior of the action until we added the possibility to export secrets as step's output. Also, the documentation is adjusted to reflect these changes.
1 parent ffba2a6 commit 0a7975f

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

.github/workflows/test.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ jobs:
1515
- name: Configure 1Password Connect
1616
uses: ./configure # 1password/load-secrets-action/configure@<version>
1717
with:
18-
connect-host: http://localhost:8080
18+
connect-host: localhost:8080
1919
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
2020
- name: Load secrets
2121
id: load_secrets
2222
uses: ./ # 1password/load-secrets-action@<version>
23+
with:
24+
export-env: false
2325
env:
2426
SECRET: op://acceptance-tests/test-secret/password
2527
SECRET_IN_SECTION: op://acceptance-tests/test-secret/test-section/password
@@ -48,8 +50,6 @@ jobs:
4850
- name: Load secrets
4951
id: load_secrets
5052
uses: ./ # 1password/load-secrets-action@<version>
51-
with:
52-
export-env: true
5353
env:
5454
SECRET: op://acceptance-tests/test-secret/password
5555
SECRET_IN_SECTION: op://acceptance-tests/test-secret/test-section/password
@@ -80,6 +80,8 @@ jobs:
8080
- name: Load secrets
8181
id: load_secrets
8282
uses: ./ # 1password/load-secrets-action@<version>
83+
with:
84+
export-env: false
8385
env:
8486
SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password
8587
SECRET_IN_SECTION: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/Section_tco6nsqycj6jcbyx63h5isxcny/doxu3mhkozcznnk5vjrkpdqayy
@@ -97,6 +99,8 @@ jobs:
9799
- name: Load secrets
98100
id: load_secrets
99101
uses: ./ # 1password/load-secrets-action@<version>
102+
with:
103+
export-env: false
100104
env:
101105
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
102106
SECRET: op://acceptance-tests/test-secret/password
@@ -115,8 +119,6 @@ jobs:
115119
- name: Load secrets
116120
id: load_secrets
117121
uses: ./ # 1password/load-secrets-action@<version>
118-
with:
119-
export-env: true
120122
env:
121123
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
122124
SECRET: op://acceptance-tests/test-secret/password
@@ -131,6 +133,8 @@ jobs:
131133
- name: Load secrets
132134
id: load_secrets
133135
uses: ./ # 1password/load-secrets-action@<version>
136+
with:
137+
export-env: false
134138
env:
135139
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
136140
SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password
@@ -149,6 +153,8 @@ jobs:
149153
- name: Load secrets
150154
id: load_secrets
151155
uses: ./ # 1password/load-secrets-action@<version>
156+
with:
157+
export-env: false
152158
env:
153159
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
154160
SECRET: op://acceptance-tests/test-secret/password

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
- name: Load secret
4444
id: op-load-secret
4545
uses: 1password/load-secrets-action@v1
46+
with:
47+
export-env: false
4648
env:
4749
OP_CONNECT_HOST: <Your Connect instance URL>
4850
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }}
@@ -77,6 +79,8 @@ jobs:
7779
- name: Load Docker credentials
7880
id: load-docker-credentials
7981
uses: 1password/load-secrets-action@v1
82+
with:
83+
export-env: false
8084
env:
8185
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }}
8286
DOCKERHUB_USERNAME: op://app-cicd/docker/username
@@ -194,7 +198,7 @@ jobs:
194198
195199
| Name | Default | Description |
196200
| ---------------- | ------- | ---------------------------------------------------------------------------------- |
197-
| `export-env` | `false` | Export the loaded secrets as environment variables |
201+
| `export-env` | `true` | Export the loaded secrets as environment variables |
198202
| `unset-previous` | `false` | Whether to unset environment variables populated by 1Password in earlier job steps |
199203

200204
## Secrets Reference Syntax

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inputs:
1010
default: false
1111
export-env:
1212
description: Export the secrets as environment variables
13-
default: false
13+
default: true
1414
runs:
1515
using: 'node16'
1616
main: 'dist/index.js'

entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ auth_type=$CONNECT
1414
managed_variables_var="OP_MANAGED_VARIABLES"
1515
IFS=','
1616

17+
if [[ "$OP_CONNECT_HOST" != "http://"* ]] && [[ "$OP_CONNECT_HOST" != "https://"* ]]; then
18+
export OP_CONNECT_HOST="http://"$OP_CONNECT_HOST
19+
fi
20+
1721
# Unset all secrets managed by 1Password if `unset-previous` is set.
1822
unset_prev_secrets() {
1923
if [ "$INPUT_UNSET_PREVIOUS" == "true" ]; then

0 commit comments

Comments
 (0)