@@ -39,30 +39,44 @@ unset_prev_secrets() {
3939
4040# Install op-cli
4141install_op_cli () {
42+ # Create a temporary directory where the CLI is installed
4243 OP_INSTALL_DIR=" $( mktemp -d) "
4344 if [[ ! -d " $OP_INSTALL_DIR " ]]; then
4445 echo " Install dir $OP_INSTALL_DIR not found"
4546 exit 1
4647 fi
4748 export OP_INSTALL_DIR
4849 echo " ::debug::OP_INSTALL_DIR: ${OP_INSTALL_DIR} "
50+
51+ # Get the latest stable version of the CLI
52+ OP_CLI_VERSION=" v$( curl https://app-updates.agilebits.com/check/1/0/CLI2/en/2.0.0/N -s | jq -r .version) "
53+
4954 if [[ " $OSTYPE " == " linux-gnu" * ]]; then
50- ARCHITECTURE=" "
51- if [[ " $( uname -m) " == " x86_64" ]]; then
52- ARCHITECTURE=" amd64"
53- elif [[ " $( uname -m) " == " aarch64" ]]; then
54- ARCHITECTURE=" arm64"
55- else
56- echo " Unsupported architecture"
55+ # Get runner's architecture
56+ ARCH=$( uname -m)
57+ if [[ " $( getconf LONG_BIT) " = 32 ]]; then
58+ ARCH=" 386"
59+ elif [[ " $ARCH " == " x86_64" ]]; then
60+ ARCH=" amd64"
61+ elif [[ " $ARCH " == " aarch64" ]]; then
62+ ARCH=" arm64"
63+ fi
64+
65+ if [[ " $ARCH " != " 386" ]] && [[ " $ARCH " != " amd64" ]] && [[ " $ARCH " != " arm" ]] && [[ " $ARCH " != " arm64" ]]; then
66+ echo " Unsupported architecture for the 1Password CLI: $ARCH ."
5767 exit 1
5868 fi
59- curl -sSfLo op.zip " https://cache.agilebits.com/dist/1P/op2/pkg/v2.18.0/op_linux_${ARCHITECTURE} _v2.18.0.zip"
69+
70+ curl -sSfLo op.zip " https://cache.agilebits.com/dist/1P/op2/pkg/${OP_CLI_VERSION} /op_linux_${ARCH} _${OP_CLI_VERSION} .zip"
6071 unzip -od " $OP_INSTALL_DIR " op.zip && rm op.zip
6172 elif [[ " $OSTYPE " == " darwin" * ]]; then
62- curl -sSfLo op.pkg " https://cache.agilebits.com/dist/1P/op2/pkg/v2.18.0/op_apple_universal_v2.18.0 .pkg"
73+ curl -sSfLo op.pkg " https://cache.agilebits.com/dist/1P/op2/pkg/${OP_CLI_VERSION} /op_apple_universal_ ${OP_CLI_VERSION} .pkg"
6374 pkgutil --expand op.pkg temp-pkg
6475 tar -xvf temp-pkg/op.pkg/Payload -C " $OP_INSTALL_DIR "
6576 rm -rf temp-pkg && rm op.pkg
77+ else
78+ echo " Operating system not supported yet for this GitHub Action: $OSTYPE ."
79+ exit 1
6680 fi
6781}
6882
@@ -97,25 +111,28 @@ populating_secret() {
97111 done
98112 unset IFS
99113
100- if [ " $INPUT_EXPORT_ENV " == " true " ] ; then
101- # To support multiline secrets , we'll use the heredoc syntax to populate the environment variables.
102- # As the heredoc identifier, we'll use a randomly generated 64-character string,
103- # so that collisions are practically impossible.
104- random_heredoc_identifier= $( openssl rand -hex 32)
114+ # To support multiline secrets, we'll use the heredoc syntax to populate the environment variables.
115+ # As the heredoc identifier , we'll use a randomly generated 64-character string,
116+ # so that collisions are practically impossible.
117+ # Read more: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
118+ delimiter= " $( openssl rand -hex 32) "
105119
120+ if [ " $INPUT_EXPORT_ENV " == " true" ]; then
106121 {
107122 # Populate env var, using heredoc syntax with generated identifier
108- echo " $env_var <<${random_heredoc_identifier } "
123+ echo " $env_var <<${delimiter } "
109124 echo " $secret_value "
110- echo " ${random_heredoc_identifier } "
125+ echo " ${delimiter } "
111126 } >> $GITHUB_ENV
112127 echo " GITHUB_ENV: $( cat $GITHUB_ENV ) "
113128
114129 else
115- # Prepare the secret_value to be outputed properly (especially multiline secrets)
116- secret_value=$( echo " $secret_value " | awk -v ORS=' %0A' ' 1' )
117-
118- echo " ::set-output name=$env_var ::$secret_value "
130+ {
131+ # Populate env var, using heredoc syntax with generated identifier
132+ echo " $env_var <<${delimiter} "
133+ echo " $secret_value "
134+ echo " ${delimiter} "
135+ } >> $GITHUB_OUTPUT
119136 fi
120137
121138 managed_variables+=(" $env_var " )
0 commit comments