File tree Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Expand file tree Collapse file tree 2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -39,12 +39,12 @@ jobs:
39
39
run : printenv
40
40
- name : Assert removed secrets
41
41
run : ./tests/assert-env-unset.sh
42
- - name : Load secret again
42
+ - name : Load secrets by vault and item titles
43
43
uses : ./ # 1password/load-secrets-action@<version>
44
44
env :
45
- SECRET : op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca /password
46
- SECRET_IN_SECTION : op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca /test-section/password
47
- MULTILINE_SECRET : op://v5pz6venw4roosmkzdq2nhpv6u/ghtz3jvcc6dqmzc53d3r3eskge /notesPlain
45
+ SECRET : op://acceptance-tests/test-secret /password
46
+ SECRET_IN_SECTION : op://acceptance-tests/test-secret /test-section/password
47
+ MULTILINE_SECRET : op://acceptance-tests/multiline-secret /notesPlain
48
48
- name : Print environment variables with masked secrets
49
49
run : printenv
50
50
- name : Assert test secret values again
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ if [ "$INPUT_UNSET_PREVIOUS" == "true" ]; then
27
27
managed_variables=()
28
28
fi
29
29
30
+ curl_headers=(-H " Content-Type: application/json" -H " Authorization: Bearer $OP_CONNECT_TOKEN " )
31
+
30
32
# Iterate over environment varables to find 1Password references, load the secret values,
31
33
# and make them available as environment variables in the next steps.
32
34
IFS=$' \n '
@@ -70,8 +72,27 @@ for possible_ref in $(printenv | grep "=op://" | grep -v "^#"); do
70
72
section=" "
71
73
fi
72
74
75
+ if [[ $( echo -n $( echo $vault | grep " ^[a-z0-9]*$" ) | wc -c) -ne 26 ]]; then
76
+ echo " Getting vault ID from vault name: $vault "
77
+ vault=$( curl -sSf " ${curl_headers[@]} " " $OP_CONNECT_HOST /v1/vaults?filter=name%20eq%20%22$vault %22" | jq -r ' .[0] | .id' )
78
+ if [ -z " $vault " ]; then
79
+ echo " Could not find vault ID for vault: $vault "
80
+ exit 1
81
+ fi
82
+ fi
83
+
84
+ if [[ $( echo -n $( echo $item | grep " ^[a-z0-9]*$" ) | wc -c) -ne 26 ]]; then
85
+ echo " Getting item ID from vault $vault ..."
86
+ item=$( curl -sSf " ${curl_headers[@]} " " $OP_CONNECT_HOST /v1/vaults/$vault /items?filter=title%20eq%20%22$item %22" | jq -r ' .[0] | .id' )
87
+ if [ -z " $item " ]; then
88
+ echo " Could not find item ID for item: $item "
89
+ exit 1
90
+ fi
91
+ fi
92
+
73
93
echo " Loading item $item from vault $vault ..."
74
- item_json=$( curl -sSf -H " Content-Type: application/json" -H " Authorization: Bearer $OP_CONNECT_TOKEN " " $OP_CONNECT_HOST /v1/vaults/$vault /items/$item " )
94
+ item_json=$( curl -sSf " ${curl_headers[@]} " " $OP_CONNECT_HOST /v1/vaults/$vault /items/$item " )
95
+
75
96
jq_field_selector=" .id == \" $field \" or .label == \" $field \" "
76
97
jq_section_selector=" .section == null"
77
98
You can’t perform that action at this time.
0 commit comments