add secrets #1

Merged
jamie merged 30 commits from feature/add-secrets into main 2025-02-27 14:16:41 +00:00
Showing only changes of commit 00d5a53db9 - Show all commits

View File

@ -34,34 +34,32 @@ runs:
shell: sh shell: sh
run: | run: |
bw login --apikey bw login --apikey
export BW_SESSION=$(bw unlock '${{ inputs.WARDEN_PASSWORD }}' --raw) BW_SESSION=$(bw unlock '${{ inputs.password }}' --raw)
echo "BW_SESSION=$BW_SESSION" >> $GITHUB_ENV echo "BW_SESSION=$BW_SESSION" >> $GITHUB_ENV
env: env:
BW_CLIENTID: "${{ inputs.client-id }}" BW_CLIENTID: "${{ inputs.client-id }}"
BW_CLIENTSECRET: "${{ inputs.client-secret }}" BW_CLIENTSECRET: "${{ inputs.client-secret }}"
- name: Retrieve Secrets - name: Retrieve Secrets
shell: bash shell: sh
run: | run: |
if [[ -z "$BW_SESSION" ]]; then if [ -z "$BW_SESSION" ]; then
echo "❌ BW_SESSION is not set. Please log in to Bitwarden first." echo "❌ BW_SESSION is not set. Please log in to Bitwarden first."
exit 1 exit 1
fi fi
echo "${{ inputs.secrets }}" | while IFS='>' read -r SECRET_ID ENV_VAR; do echo "${{ inputs.secrets }}" | while IFS='>' read SECRET_ID ENV_VAR; do
# Trim whitespace SECRET_ID=$(echo "$SECRET_ID" | sed 's/^ *//;s/ *$//')
SECRET_ID=$(echo "$SECRET_ID" | xargs) ENV_VAR=$(echo "$ENV_VAR" | sed 's/^ *//;s/ *$//')
ENV_VAR=$(echo "$ENV_VAR" | xargs)
# Skip empty or invalid lines if [ -z "$SECRET_ID" ] || [ -z "$ENV_VAR" ]; then
if [[ -z "$SECRET_ID" || -z "$ENV_VAR" ]]; then
continue continue
fi fi
echo "🔍 Retrieving secret: $SECRET_ID" echo "🔍 Retrieving secret: $SECRET_ID"
SECRET_VALUE=$(bw get notes "$SECRET_ID" --session "$BW_SESSION" --raw 2>/dev/null) SECRET_VALUE=$(bw get notes "$SECRET_ID" --session "$BW_SESSION" --raw 2>/dev/null)
if [[ -n "$SECRET_VALUE" ]]; then if [ -n "$SECRET_VALUE" ]; then
echo "$ENV_VAR<<EOF" >> $GITHUB_ENV echo "$ENV_VAR<<EOF" >> $GITHUB_ENV
echo "$SECRET_VALUE" >> $GITHUB_ENV echo "$SECRET_VALUE" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV