From 445f3224bde3550e5361d85def509c36762344d2 Mon Sep 17 00:00:00 2001 From: Johan Rooijakkers Date: Wed, 26 Feb 2025 15:57:45 +0100 Subject: [PATCH] update unlock vault --- action.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 31fa5b1..ebbd86a 100644 --- a/action.yml +++ b/action.yml @@ -33,8 +33,23 @@ runs: - name: Unlock Vault shell: sh run: | - bw login --apikey - echo "BW_SESSION=$(bw unlock '${{ inputs.password }}' --raw)" >> $GITHUB_ENV + # Ensure Bitwarden is logged in + if ! bw login --check; then + bw login --apikey + fi + + # Unlock the vault and store the session key + BW_SESSION=$(bw unlock "${{ inputs.password }}" --raw) + + # Verify if BW_SESSION is set correctly + if [ -n "$BW_SESSION" ]; then + echo "BW_SESSION=$BW_SESSION" >> "$GITHUB_ENV" + export BW_SESSION + echo "✅ Vault unlocked successfully!" + else + echo "❌ Failed to unlock Bitwarden vault" + exit 1 + fi env: BW_CLIENTID: ${{ inputs.client-id }} BW_CLIENTSECRET: ${{ inputs.client-secret }} @@ -42,7 +57,6 @@ runs: - name: Retrieve Requested Secrets shell: sh run: | - # Convert comma-separated secrets into a list OLDIFS=$IFS IFS=',' set -- ${{ inputs.secrets }}