add secrets #1
44
action.yml
44
action.yml
@ -1,23 +1,55 @@
|
|||||||
name: Auth Warden
|
name: Auth Warden
|
||||||
description: Authenticate with Bitwarden
|
description: Authenticate with Bitwarden and retrieve dynamic secrets
|
||||||
author: Jamie Schouten
|
author: Jamie Schouten
|
||||||
|
|
||||||
inputs:
|
inputs:
|
||||||
email:
|
email:
|
||||||
description: 'email'
|
description: 'Bitwarden email'
|
||||||
required: true
|
required: true
|
||||||
password:
|
password:
|
||||||
description: 'password'
|
description: 'Bitwarden password'
|
||||||
required: true
|
required: true
|
||||||
server:
|
server:
|
||||||
description: 'Bitwarden server'
|
description: 'Bitwarden server'
|
||||||
required: false
|
required: false
|
||||||
default: ${{ vars.WARDEN_URL }}
|
default: ${{ vars.WARDEN_URL }}
|
||||||
|
secrets:
|
||||||
|
description: "One or more secret Ids to retrieve and the corresponding GitHub environment variable name to set"
|
||||||
|
required: true
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- name: Auth Warden
|
- name: Configure Bitwarden Server
|
||||||
|
shell: sh
|
||||||
|
run: bw config server ${{ inputs.server }}
|
||||||
|
|
||||||
|
- name: Unlock Vault
|
||||||
shell: sh
|
shell: sh
|
||||||
run: |
|
run: |
|
||||||
bw config server ${{ inputs.server }}
|
bw login --apikey
|
||||||
export BW_SESSION=$(bw login '${{ inputs.email }}' '${{ inputs.password }}' --raw)
|
export BW_SESSION=$(bw unlock '${{ secrets.WARDEN_PASSWORD }}' --raw)
|
||||||
|
env:
|
||||||
|
BW_CLIENTID: ${{ secrets.WARDEN_CLIENT_ID }}
|
||||||
|
BW_CLIENTSECRET: ${{ secrets.WARDEN_CLIENT_SECRET }}
|
||||||
|
|
||||||
|
- name: Retrieve Requested Secrets
|
||||||
|
shell: sh
|
||||||
|
run: |
|
||||||
|
IFS=',' read -r -a secret_pairs <<< "${{ inputs.secrets }}"
|
||||||
|
for pair in "${secret_pairs[@]}"; do
|
||||||
|
SECRET_ID=$(echo "$pair" | cut -d'=' -f1)
|
||||||
|
ENV_VAR=$(echo "$pair" | cut -d'=' -f2)
|
||||||
|
|
||||||
|
echo "Retrieving secret: $SECRET_ID..."
|
||||||
|
SECRET_VALUE=$(bw get item "$SECRET_ID" --session "$BW_SESSION")
|
||||||
|
|
||||||
|
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
|
||||||
|
env:
|
||||||
|
BW_SESSION: ${{ env.BW_SESSION }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user