From 3236089d6434717e5e4ab34cf4775033192a0be2 Mon Sep 17 00:00:00 2001 From: Martin Helmich Date: Mon, 19 Feb 2024 08:40:46 +0100 Subject: [PATCH] Use config from global environment in non-interactive mode --- .github/workflows/tests.yml | 1 + install.yaml | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b206286..1d682db 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,6 +32,7 @@ jobs: - uses: ddev/github-action-add-on-test@v1 env: MITTWALD_API_TOKEN: foo + MITTWALD_APP_INSTALLATION_ID: a-XXXXXX with: ddev_version: ${{ matrix.ddev_version }} token: ${{ secrets.GITHUB_TOKEN }} diff --git a/install.yaml b/install.yaml index adba629..2cb28ec 100644 --- a/install.yaml +++ b/install.yaml @@ -17,13 +17,18 @@ pre_install_actions: #ddev-nodisplay if !( {{ contains "MITTWALD_API_TOKEN" (list .DdevGlobalConfig.web_environment | toString) }} || {{ contains "MITTWALD_API_TOKEN" (list .DdevProjectConfig.web_environment | toString) }} ); then if [[ -n "${DDEV_NONINTERACTIVE}" ]] ; then - echo "MITTWALD_API_TOKEN not set; please provide one in the web_environment configuration" >&2 - exit 1 + if [[ -n "${MITTWALD_API_TOKEN}" ]] ; then + ddev config global --web-environment-add MITTWALD_API_TOKEN=${MITTWALD_API_TOKEN} + echo "MITTWALD_API_TOKEN set globally" + else + echo "MITTWALD_API_TOKEN not set; please provide one in the web_environment configuration" >&2 + exit 1 + fi + else + read -s token + ddev config global --web-environment-add MITTWALD_API_TOKEN=${token} + echo "MITTWALD_API_TOKEN set globally" fi - - read -s token - ddev config global --web-environment-add MITTWALD_API_TOKEN=${token} - echo "MITTWALD_API_TOKEN set globally" fi - | @@ -37,11 +42,16 @@ pre_install_actions: #ddev-nodisplay if !( {{ contains "MITTWALD_APP_INSTALLATION_ID" (list .DdevProjectConfig.web_environment | toString) }} ); then if [[ -n "${DDEV_NONINTERACTIVE}" ]] ; then - echo "MITTWALD_APP_INSTALLATION_ID not set; please provide one in the web_environment configuration" >&2 - exit 1 + if [[ -n "${MITTWALD_APP_INSTALLATION_ID}" ]] ; then + ddev config --web-environment-add MITTWALD_APP_INSTALLATION_ID=${MITTWALD_APP_INSTALLATION_ID} + else + echo "MITTWALD_APP_INSTALLATION_ID not set; please provide one in the web_environment configuration" >&2 + exit 1 + fi + else + read app_id + ddev config --web-environment-add MITTWALD_APP_INSTALLATION_ID=${app_id} fi - read app_id - ddev config --web-environment-add MITTWALD_APP_INSTALLATION_ID=${app_id} fi