From 5b5f12f1c6325e4ee819c23b44c020a5837c54aa Mon Sep 17 00:00:00 2001 From: Edward J Date: Thu, 22 Aug 2024 16:08:45 -0700 Subject: [PATCH] Add multi-file support for config --- action.yaml | 13 ++++++++++++- config.sh | 27 --------------------------- 2 files changed, 12 insertions(+), 28 deletions(-) delete mode 100755 config.sh diff --git a/action.yaml b/action.yaml index 5b27fbf..ef2cb5f 100644 --- a/action.yaml +++ b/action.yaml @@ -44,7 +44,18 @@ runs: - name: Deploy Config shell: bash - run: ${{ github.action_path }}/config.sh + run: | + # Iterate over the sources and set the environment variables + params=() + for filename in ${{ inputs['compose-files'] }}; do + params+=("-f") + params+=("$filename") + done + for source in $CONFIG_ENV_VARS; do + echo "Updating $source" + echo defang config "${params[@]}" set -e $source + defang config "${params[@]}" set -e $source + done working-directory: ${{ inputs.cwd }} env: CONFIG_ENV_VARS: ${{ inputs['config-env-vars'] }} diff --git a/config.sh b/config.sh deleted file mode 100755 index a0b48fd..0000000 --- a/config.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -# CONFIG_ENV_VARS is a space separated list of environment variables. i.e. "ENV_VAR1 ENV_VAR2 ENV_VAR3" - -if [ -z "$CONFIG_ENV_VARS" ]; then - echo "No environment variables to set." - echo "Moving on..." - exit 0 -fi - -echo "Setting config from environment variables..." - -# Function to handle setting the environment variables -set_env_var() { - local source=$1 - - echo "Updating $source" - defang config set -e $source -} - -# Split the CONFIG_ENV_VARS string by whitespace -IFS=' ' read -r -a sources <<< "$CONFIG_ENV_VARS" - -# Iterate over the sources and set the environment variables -for source in "${sources[@]}"; do - set_env_var "$source" -done \ No newline at end of file