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 b22ebd4ac7 - Show all commits

View File

@ -28,7 +28,7 @@ runs:
steps: steps:
- name: Configure Bitwarden Server - name: Configure Bitwarden Server
shell: sh shell: sh
run: bw config server ${{ inputs.server }} run: bw config server "${{ inputs.server }}"
- name: Unlock Vault - name: Unlock Vault
shell: sh shell: sh
@ -36,8 +36,8 @@ runs:
bw login --apikey bw login --apikey
echo "BW_SESSION=$(bw unlock '${{ inputs.password }}' --raw)" >> "$GITHUB_ENV" echo "BW_SESSION=$(bw unlock '${{ inputs.password }}' --raw)" >> "$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 Requested Secrets - name: Retrieve Requested Secrets
shell: bash shell: bash
@ -48,7 +48,7 @@ runs:
fi fi
echo "${{ inputs.secrets }}" | while IFS='>' read -r SECRET_ID ENV_VAR; do echo "${{ inputs.secrets }}" | while IFS='>' read -r SECRET_ID ENV_VAR; do
# Trim whitespace
SECRET_ID=$(echo "$SECRET_ID" | xargs) SECRET_ID=$(echo "$SECRET_ID" | xargs)
ENV_VAR=$(echo "$ENV_VAR" | xargs) ENV_VAR=$(echo "$ENV_VAR" | xargs)
@ -61,11 +61,9 @@ runs:
SECRET_VALUE=$(bw get notes "$SECRET_ID" --session "$BW_SESSION" 2>/dev/null) SECRET_VALUE=$(bw get notes "$SECRET_ID" --session "$BW_SESSION" 2>/dev/null)
if [[ -n "$SECRET_VALUE" ]]; then if [[ -n "$SECRET_VALUE" ]]; then
echo "$ENV_VAR=$SECRET_VALUE" >> "$GITHUB_ENV" echo "$ENV_VAR=\"$SECRET_VALUE\"" >> "$GITHUB_ENV"
echo "✅ Stored $SECRET_ID in $ENV_VAR" echo "✅ Stored $SECRET_ID in $ENV_VAR"
else else
echo "❌ Failed to retrieve secret: $SECRET_ID" echo "❌ Failed to retrieve secret: $SECRET_ID"
fi fi
done done