From 8fe985435093edb32acfa1d87d987be0d2e06bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lio=E6=9D=8E=E6=AD=90?= Date: Thu, 25 Jun 2026 12:34:35 -0700 Subject: [PATCH 1/4] feat: config variable initialization only Added new input for initializing config variables and updated related logic in the action. --- action.yaml | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/action.yaml b/action.yaml index 8dc9373..caf2bfe 100644 --- a/action.yaml +++ b/action.yaml @@ -11,7 +11,11 @@ inputs: required: false default: "" config-env-vars: - description: "Environment variables deploy as config. Format: 'VAR1 VAR2 VAR3'" + description: "Environment variables to deploy as config. Format: 'VAR1 VAR2 VAR3'" + required: false + default: "" + config-env-vars-init: + description: "Initialize config variables in this list with if they are not already set. Format: 'VAR1 VAR2 VAR3'" required: false default: "" config-vars-init-random: @@ -117,7 +121,7 @@ runs: - name: Defang Config Set shell: bash - if: ${{ inputs['config-env-vars'] != '' || inputs['config-vars-init-random'] != '' }} + if: ${{ inputs['config-env-vars'] != '' || inputs['config-vars-init-random'] != '' || inputs['config-env-vars-init'] != '' }} run: | # Build compose file parameters params=() @@ -126,9 +130,9 @@ runs: params+=("$filename") done - # Check for empty environment variables (only for regular config vars) + # Check for empty environment variables (only for config vars from env) empty=() - for source in $CONFIG_ENV_VARS; do + for source in $CONFIG_ENV_VARS $CONFIG_ENV_VARS_INIT; do if [ -z "${!source}" ]; then empty+=("$source") fi @@ -146,10 +150,17 @@ runs: fi # Set random config variables - if [ -n "$CONFIG_ENV_VARS_INIT_RANDOM" ]; then + if [ -n "$CONFIG_VARS_INIT_RANDOM" ]; then echo "Initialize randomly generated configs..." - echo defang config "${params[@]}" set --if-not-set --random $CONFIG_ENV_VARS_INIT_RANDOM - defang config "${params[@]}" set --if-not-set --random $CONFIG_ENV_VARS_INIT_RANDOM + echo defang config "${params[@]}" set --if-not-set --random $CONFIG_VARS_INIT_RANDOM + defang config "${params[@]}" set --if-not-set --random $CONFIG_VARS_INIT_RANDOM + fi + + # Set init config variables + if [ -n "$CONFIG_ENV_VARS_INIT" ]; then + echo "Initialize configs..." + echo defang config "${params[@]}" set --if-not-set -e $CONFIG_ENV_VARS_INIT + defang config "${params[@]}" set --if-not-set -e $CONFIG_ENV_VARS_INIT fi # Set regular config variables @@ -162,7 +173,8 @@ runs: env: COMPOSE_FILES: ${{ inputs['compose-files'] }} CONFIG_ENV_VARS: ${{ inputs['config-env-vars'] }} - CONFIG_ENV_VARS_INIT_RANDOM: ${{ inputs['config-vars-init-random'] }} + CONFIG_ENV_VARS_INIT: ${{ inputs['config-env-vars-init'] }} + CONFIG_VARS_INIT_RANDOM: ${{ inputs['config-vars-init-random'] }} - name: Defang ${{ inputs['command'] }} id: command @@ -189,7 +201,7 @@ runs: esac # Unset config vars to avoid Defang CLI warning user that config from shell env is ignored - unset $CONFIG_ENV_VARS_INIT_RANDOM $CONFIG_ENV_VARS dont_complain_on_empty + unset $CONFIG_VARS_INIT_RANDOM $CONFIG_ENV_VARS dont_complain_on_empty echo defang $COMMAND "${params[@]}" if [[ "$CAPTURE_OUTPUT" =~ ^(y|Y|yes|Yes|YES|true|True|TRUE|on|On|ON|1)$ ]]; then @@ -204,7 +216,7 @@ runs: COMMAND: ${{ inputs['command'] }} COMPOSE_FILES: ${{ inputs['compose-files'] }} CONFIG_ENV_VARS: ${{ inputs['config-env-vars'] }} - CONFIG_ENV_VARS_INIT_RANDOM: ${{ inputs['config-vars-init-random'] }} + CONFIG_VARS_INIT_RANDOM: ${{ inputs['config-vars-init-random'] }} CAPTURE_OUTPUT: ${{ inputs['capture-output'] }} - name: Forward output From 438c3b909359c2e8a1379bcf662ce6f382532a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lio=E6=9D=8E=E6=AD=90?= Date: Thu, 25 Jun 2026 12:36:46 -0700 Subject: [PATCH 2/4] Update action.yaml to include CONFIG_VARS_INIT Added CONFIG_VARS_INIT to the unset command and environment variables. --- action.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index caf2bfe..7f0e16e 100644 --- a/action.yaml +++ b/action.yaml @@ -201,7 +201,7 @@ runs: esac # Unset config vars to avoid Defang CLI warning user that config from shell env is ignored - unset $CONFIG_VARS_INIT_RANDOM $CONFIG_ENV_VARS dont_complain_on_empty + unset $CONFIG_VARS_INIT_RANDOM $CONFIG_ENV_VARS $CONFIG_ENV_VARS_INIT dont_complain_on_empty echo defang $COMMAND "${params[@]}" if [[ "$CAPTURE_OUTPUT" =~ ^(y|Y|yes|Yes|YES|true|True|TRUE|on|On|ON|1)$ ]]; then @@ -216,6 +216,7 @@ runs: COMMAND: ${{ inputs['command'] }} COMPOSE_FILES: ${{ inputs['compose-files'] }} CONFIG_ENV_VARS: ${{ inputs['config-env-vars'] }} + CONFIG_VARS_INIT: ${{ inputs['config-env-vars-init'] }} CONFIG_VARS_INIT_RANDOM: ${{ inputs['config-vars-init-random'] }} CAPTURE_OUTPUT: ${{ inputs['capture-output'] }} From a86f3489f0052b39d902a8d67d9aab805bc02bbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lio=E6=9D=8E=E6=AD=90?= Date: Thu, 25 Jun 2026 12:38:00 -0700 Subject: [PATCH 3/4] Rename CONFIG_VARS_INIT to CONFIG_ENV_VARS_INIT --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 7f0e16e..3f372da 100644 --- a/action.yaml +++ b/action.yaml @@ -216,7 +216,7 @@ runs: COMMAND: ${{ inputs['command'] }} COMPOSE_FILES: ${{ inputs['compose-files'] }} CONFIG_ENV_VARS: ${{ inputs['config-env-vars'] }} - CONFIG_VARS_INIT: ${{ inputs['config-env-vars-init'] }} + CONFIG_ENV_VARS_INIT: ${{ inputs['config-env-vars-init'] }} CONFIG_VARS_INIT_RANDOM: ${{ inputs['config-vars-init-random'] }} CAPTURE_OUTPUT: ${{ inputs['capture-output'] }} From 7352d5f5c439867fa571f630c993839f85744f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lio=E6=9D=8E=E6=AD=90?= Date: Thu, 25 Jun 2026 12:39:54 -0700 Subject: [PATCH 4/4] Update action.yaml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- action.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yaml b/action.yaml index 3f372da..4c6fa8e 100644 --- a/action.yaml +++ b/action.yaml @@ -15,7 +15,7 @@ inputs: required: false default: "" config-env-vars-init: - description: "Initialize config variables in this list with if they are not already set. Format: 'VAR1 VAR2 VAR3'" + description: "Initialize config variables in this list from environment values if they are not already set. Format: 'VAR1 VAR2 VAR3'" required: false default: "" config-vars-init-random: