elysium-actions/action.yml

51 lines
1.8 KiB
YAML
Raw Normal View History

2024-02-13 23:37:58 -07:00
# Based on https://github.com/zerodays/action-infisical/blob/master/action.yml
name: 'Elysium Infisical Secrets'
description: 'Fetch secrets from Infisical and add them to the env'
inputs:
infisical-token:
description: 'Infisical API Token'
required: true
2024-02-15 17:51:14 -07:00
secret-envs:
2024-02-15 17:42:49 -07:00
description: 'The environments to fetch secrets for (Example: ci or ci,prod,edge )'
2024-02-13 23:37:58 -07:00
required: true
2024-02-15 17:42:49 -07:00
secret-paths:
description: 'Secret paths for the secrets (Must match the order of envs! Example: /main or /main,/alt-main)'
2024-02-14 19:50:41 -07:00
required: true
2024-02-13 23:37:58 -07:00
api-url:
2024-02-14 19:50:41 -07:00
description: 'Infisical API URL (defaults to https://infisical.dunemask.dev/api)'
2024-02-13 23:37:58 -07:00
required: false
2024-02-14 19:50:41 -07:00
default: 'https://infisical.dunemask.dev/api'
2024-02-13 23:37:58 -07:00
runs:
using: 'composite'
steps:
2024-02-14 16:44:28 -07:00
- name: Infisical CLI install
shell: bash
run: |
2024-02-15 17:42:49 -07:00
# Install Infisical Binary
2024-02-14 16:47:02 -07:00
curl -s -L https://github.com/Infisical/infisical/releases/download/infisical-cli%2Fv0.16.10/infisical_0.16.10_linux_amd64.tar.gz | tar xvz
2024-02-15 17:42:49 -07:00
# Get paths and envs into list
paths="${{ inputs.secret-paths }}"
2024-02-15 17:51:14 -07:00
envs="${{ inputs.secret-envs }}"
2024-02-15 17:42:49 -07:00
path_list=( $(echo $paths | sed "s/,/ /g") )
env_list=( $(echo $envs | sed "s/,/ /g") )
path_len=${#path_list[@]}
env_len=${#env_list[@]}
# Ensure lengths match
2024-02-15 18:02:58 -07:00
if [ "$path_len" != "$env_len" ];
then
echo "Input must match the output!"
exit 1;
fi
2024-02-15 17:42:49 -07:00
# For each environment
2024-02-15 18:02:58 -07:00
for i in "${!path_list[@]}";
do
echo "Getting secrets from path '${path_list[i]}' from '${env_list[i]}'"
./infisical export --domain ${{ inputs.api-url }} --token ${{ inputs.infisical-token}} --env "${env_list[i]}" --path "${path_list[i]}" >> $GITHUB_ENV;
done
2024-02-15 17:42:49 -07:00
2024-02-13 23:37:58 -07:00
- shell: bash
run: echo "Secrets added to environment!".