This commit is contained in:
Johan Rooijakkers 2025-02-26 17:47:52 +01:00
parent 0b36a68d06
commit bcebea6713

View File

@ -48,25 +48,24 @@ runs:
fi
echo "${{ inputs.secrets }}" | while IFS='>' read -r SECRET_ID ENV_VAR; do
# Trim whitespace
SECRET_ID=$(echo "$SECRET_ID" | xargs)
ENV_VAR=$(echo "$ENV_VAR" | xargs)
# Validate input format
if [[ -z "$SECRET_ID" || -z "$ENV_VAR" ]]; then
echo "❌ Invalid secret pair format: $SECRET_ID > $ENV_VAR"
continue
fi
SECRET_ID=$(echo "$SECRET_ID" | xargs)
ENV_VAR=$(echo "$ENV_VAR" | xargs)
echo "🔍 Retrieving secret: $SECRET_ID..."
# Skip empty or invalid lines
if [[ -z "$SECRET_ID" || -z "$ENV_VAR" ]]; then
continue
fi
echo "🔍 Retrieving secret: $SECRET_ID..."
SECRET_VALUE=$(bw get notes "$SECRET_ID" --session "$BW_SESSION" 2>/dev/null)
if [[ -n "$SECRET_VALUE" ]]; then
echo "$ENV_VAR=$SECRET_VALUE" >> "$GITHUB_ENV"
echo "✅ Stored $SECRET_ID in $ENV_VAR"
else
echo "❌ Failed to retrieve secret: $SECRET_ID"
fi
done
# Fetch secret from Bitwarden
SECRET_VALUE=$(bw get notes "$SECRET_ID" --session "$BW_SESSION" 2>/dev/null)
if [[ -n "$SECRET_VALUE" ]]; then
echo "$ENV_VAR=$SECRET_VALUE" >> "$GITHUB_ENV"
echo "✅ Stored $SECRET_ID in $ENV_VAR"
else
echo "❌ Failed to retrieve secret: $SECRET_ID"
fi
done