From c0af6e77b2b9a178084209e69bc60ce7deb00cee Mon Sep 17 00:00:00 2001 From: Dunemask Date: Thu, 15 Feb 2024 17:42:49 -0700 Subject: [PATCH] [FEATURE] Auto Oasis Test --- action.yml | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 5232e43..31b2fbd 100644 --- a/action.yml +++ b/action.yml @@ -5,11 +5,11 @@ inputs: infisical-token: description: 'Infisical API Token' required: true - environment: - description: 'The environment to fetch secrets for (e.g., staging, production)' + envs: + description: 'The environments to fetch secrets for (Example: ci or ci,prod,edge )' required: true - secret-path: - description: 'Secret path' + secret-paths: + description: 'Secret paths for the secrets (Must match the order of envs! Example: /main or /main,/alt-main)' required: true api-url: description: 'Infisical API URL (defaults to https://infisical.dunemask.dev/api)' @@ -21,7 +21,31 @@ runs: - name: Infisical CLI install shell: bash run: | + # Install Infisical Binary 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 - ./infisical export --domain ${{ inputs.api-url }} --token ${{ inputs.infisical-token}} --env ${{ inputs.environment }} --path ${{ inputs.secret-path }} >> $GITHUB_ENV + + # Get paths and envs into list + paths="${{ inputs.secret-paths }}" + envs="${{ inputs.envs }}" + + 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 + if [ $path_len != $env_len ]; + then + echo "Input must match the output!" + exit 1; + fi + + # For each environment + 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 + - shell: bash run: echo "Secrets added to environment!". \ No newline at end of file