From 67a4107a69b078804fda4959622b6691ed91a713 Mon Sep 17 00:00:00 2001 From: Jordan Stephens Date: Fri, 23 Jan 2026 18:01:48 -0800 Subject: [PATCH 1/9] print a url to set missing config vars --- action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yaml b/action.yaml index 3a317bc..65b5d17 100644 --- a/action.yaml +++ b/action.yaml @@ -104,6 +104,7 @@ runs: env: COMPOSE_FILES: ${{ inputs['compose-files'] }} CONFIG_ENV_VARS: ${{ inputs['config-env-vars'] }} + ENV_NAME: ${{ job.environment.name }} - name: Defang ${{ inputs['command'] }} if: ${{ inputs['command'] != '' }} From d163ec6e62311c0f4d10b41007fa4624b07ddfec Mon Sep 17 00:00:00 2001 From: muddysound Date: Mon, 26 Jan 2026 15:25:23 -0800 Subject: [PATCH 2/9] add config-vars-init-random input and use --init --random --- action.yaml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/action.yaml b/action.yaml index 65b5d17..2b7f7a0 100644 --- a/action.yaml +++ b/action.yaml @@ -14,6 +14,10 @@ inputs: description: "Environment variables deploy as config. Format: 'VAR1 VAR2 VAR3'" required: false default: "" + config-vars-init-random: + description: "Initialize config variables in this list with random values if they are not already set. Format: 'VAR1 VAR2 VAR3'" + required: false + default: "" command: description: "The command to run." required: false @@ -90,21 +94,28 @@ runs: echo "Some Defang config vars do not have values. To use Github Secrets, add" echo "these variables to your environment:" for source in "${empty[@]}"; do - echo "- $source" + if [[ " $CONFIG_ENV_VARS_INIT_RANDOM " != *" $source "* ]]; then + echo "- $source" + fi done echo "Here is a link to your repository environments settings:" echo "https://github.com/${GITHUB_REPOSITORY}/settings/environments" fi for source in $CONFIG_ENV_VARS; do echo "Updating $source" - echo defang config "${params[@]}" set -e $source - defang config "${params[@]}" set -e $source + if [[ " $CONFIG_ENV_VARS_INIT_RANDOM " == *" $source "* ]]; then + echo defang config "${params[@]}" --init --random -e $source + defang config "${params[@]}" --init --random -e $source + else + echo defang config "${params[@]}" set -e $source + defang config "${params[@]}" set -e $source + fi done working-directory: ${{ inputs.cwd }} env: COMPOSE_FILES: ${{ inputs['compose-files'] }} CONFIG_ENV_VARS: ${{ inputs['config-env-vars'] }} - ENV_NAME: ${{ job.environment.name }} + CONFIG_ENV_VARS_INIT_RANDOM: ${{ inputs['config-vars-init-random'] }} - name: Defang ${{ inputs['command'] }} if: ${{ inputs['command'] != '' }} From 750506b6cfba0ae440bc67f18fe4933dba1e13ed Mon Sep 17 00:00:00 2001 From: jordanstephens Date: Tue, 27 Jan 2026 11:30:42 -0800 Subject: [PATCH 3/9] factor out help text printing for empty config vars --- action.yaml | 22 +++------------------- scripts/print-empty.sh | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 scripts/print-empty.sh diff --git a/action.yaml b/action.yaml index 2b7f7a0..5f70df6 100644 --- a/action.yaml +++ b/action.yaml @@ -81,26 +81,10 @@ runs: params+=("-f") params+=("$filename") done - empty=() - for source in $CONFIG_ENV_VARS; do - if [ -z "${!source}" ]; then - empty+=("$source") - fi - done - # if there are any empty variables, print instructions on how to update - # the github environment variables - if [ ${#empty[@]} -gt 0 ]; then - echo "Some Defang config vars do not have values. To use Github Secrets, add" - echo "these variables to your environment:" - for source in "${empty[@]}"; do - if [[ " $CONFIG_ENV_VARS_INIT_RANDOM " != *" $source "* ]]; then - echo "- $source" - fi - done - echo "Here is a link to your repository environments settings:" - echo "https://github.com/${GITHUB_REPOSITORY}/settings/environments" - fi + # Print help text regarding empty env vars + ${{ github.action_path }}/scripts/print-empty.sh + for source in $CONFIG_ENV_VARS; do echo "Updating $source" if [[ " $CONFIG_ENV_VARS_INIT_RANDOM " == *" $source "* ]]; then diff --git a/scripts/print-empty.sh b/scripts/print-empty.sh new file mode 100644 index 0000000..50d7e6e --- /dev/null +++ b/scripts/print-empty.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +# Check for empty environment variables (only for regular config vars) +empty=() +for source in $CONFIG_ENV_VARS; do + if [ -z "${!source}" ]; then + empty+=("$source") + fi +done + +# If there are empty variables, print instructions +if [ ${#empty[@]} -gt 0 ]; then + echo "Some Defang config vars do not have values. To use Github Secrets, add" + echo "these variables to your environment:" + for source in "${empty[@]}"; do + echo "- $source" + done + echo "Here is a link to your repository environments settings:" + echo "https://github.com/${GITHUB_REPOSITORY}/settings/environments" +fi From 989635a1a5809ec8972d53fe6e76d4f27814b517 Mon Sep 17 00:00:00 2001 From: jordanstephens Date: Tue, 27 Jan 2026 11:32:00 -0800 Subject: [PATCH 4/9] set random values first, then set regular config --- action.yaml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/action.yaml b/action.yaml index 5f70df6..a735612 100644 --- a/action.yaml +++ b/action.yaml @@ -73,9 +73,9 @@ runs: - name: Defang Config Set shell: bash - if: ${{ inputs['config-env-vars'] != '' }} + if: ${{ inputs['config-env-vars'] != '' || inputs['config-vars-init-random'] != '' }} run: | - # Iterate over the sources and set the environment variables + # Build compose file parameters params=() for filename in $COMPOSE_FILES; do params+=("-f") @@ -85,15 +85,18 @@ runs: # Print help text regarding empty env vars ${{ github.action_path }}/scripts/print-empty.sh + # Set random config variables + for source in $CONFIG_ENV_VARS_INIT_RANDOM; do + echo "Setting $source to a randomly generated value" + echo defang config "${params[@]}" --if-not-set --random $source + defang config "${params[@]}" --if-not-set --random $source + done + + # Set regular config variables for source in $CONFIG_ENV_VARS; do - echo "Updating $source" - if [[ " $CONFIG_ENV_VARS_INIT_RANDOM " == *" $source "* ]]; then - echo defang config "${params[@]}" --init --random -e $source - defang config "${params[@]}" --init --random -e $source - else + echo "Updating $source" echo defang config "${params[@]}" set -e $source defang config "${params[@]}" set -e $source - fi done working-directory: ${{ inputs.cwd }} env: From 2f19cc37428d72bf27afd8c7c84ff353f4636929 Mon Sep 17 00:00:00 2001 From: jordanstephens Date: Tue, 27 Jan 2026 12:34:15 -0800 Subject: [PATCH 5/9] inline print-empty.sh --- action.yaml | 20 ++++++++++++++++++-- scripts/print-empty.sh | 21 --------------------- 2 files changed, 18 insertions(+), 23 deletions(-) delete mode 100644 scripts/print-empty.sh diff --git a/action.yaml b/action.yaml index a735612..68df9b1 100644 --- a/action.yaml +++ b/action.yaml @@ -82,8 +82,24 @@ runs: params+=("$filename") done - # Print help text regarding empty env vars - ${{ github.action_path }}/scripts/print-empty.sh + # Check for empty environment variables (only for regular config vars) + empty=() + for source in $CONFIG_ENV_VARS; do + if [ -z "${!source}" ]; then + empty+=("$source") + fi + done + + # If there are empty variables, print instructions + if [ ${#empty[@]} -gt 0 ]; then + echo "Some Defang config vars do not have values. To use Github Secrets, add" + echo "these variables to your environment:" + for source in "${empty[@]}"; do + echo "- $source" + done + echo "Here is a link to your repository environments settings:" + echo "https://github.com/${GITHUB_REPOSITORY}/settings/environments" + fi # Set random config variables for source in $CONFIG_ENV_VARS_INIT_RANDOM; do diff --git a/scripts/print-empty.sh b/scripts/print-empty.sh deleted file mode 100644 index 50d7e6e..0000000 --- a/scripts/print-empty.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -set -e - -# Check for empty environment variables (only for regular config vars) -empty=() -for source in $CONFIG_ENV_VARS; do - if [ -z "${!source}" ]; then - empty+=("$source") - fi -done - -# If there are empty variables, print instructions -if [ ${#empty[@]} -gt 0 ]; then - echo "Some Defang config vars do not have values. To use Github Secrets, add" - echo "these variables to your environment:" - for source in "${empty[@]}"; do - echo "- $source" - done - echo "Here is a link to your repository environments settings:" - echo "https://github.com/${GITHUB_REPOSITORY}/settings/environments" -fi From e82196670527b66da66643a5a309ebbf3594a965 Mon Sep 17 00:00:00 2001 From: jordanstephens Date: Tue, 27 Jan 2026 19:03:27 -0500 Subject: [PATCH 6/9] test config-vars-init-random --- .github/workflows/test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 7aaa06a..3ed7f14 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -29,6 +29,8 @@ jobs: config-env-vars: | DEFANG_GH_ACTION_TEST_ENV DEFANG_GH_ACTION_TEST_MESSAGE + config-vars-init-random: | + DEFANG_GH_ACTION_TEST_SECRET cwd: "./test" compose-files: | compose.yaml From 9fada570a28027dd74f9b0bac694873d02a553b0 Mon Sep 17 00:00:00 2001 From: jordanstephens Date: Tue, 27 Jan 2026 19:13:53 -0500 Subject: [PATCH 7/9] run test on push to branches --- .github/workflows/test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 3ed7f14..2f47026 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -4,6 +4,7 @@ on: push: branches: - main + - "**" pull_request: branches: - "**" From 256a0c051c528c48e1b80ed9ef8d8907d58f5691 Mon Sep 17 00:00:00 2001 From: jordanstephens Date: Tue, 27 Jan 2026 19:55:11 -0500 Subject: [PATCH 8/9] fix defang config set invocation --- action.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yaml b/action.yaml index 68df9b1..a8f61f7 100644 --- a/action.yaml +++ b/action.yaml @@ -104,8 +104,8 @@ runs: # Set random config variables for source in $CONFIG_ENV_VARS_INIT_RANDOM; do echo "Setting $source to a randomly generated value" - echo defang config "${params[@]}" --if-not-set --random $source - defang config "${params[@]}" --if-not-set --random $source + echo defang config "${params[@]}" set --if-not-set --random $source + defang config "${params[@]}" set --if-not-set --random $source done # Set regular config variables From 7eca44492b0bc1af706275a80cc5cd53406bdc1b Mon Sep 17 00:00:00 2001 From: jordanstephens Date: Tue, 27 Jan 2026 21:25:01 -0500 Subject: [PATCH 9/9] use nightly cli --- .github/workflows/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2f47026..29cb8bc 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -26,7 +26,7 @@ jobs: - name: Deploy uses: ./ with: - cli-version: v0.5.40 + cli-version: nightly config-env-vars: | DEFANG_GH_ACTION_TEST_ENV DEFANG_GH_ACTION_TEST_MESSAGE