From 4f86cc1a967bc9f8028131f50b51bae9b602acb1 Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 12:39:28 +1100 Subject: [PATCH 01/12] Updated deploy script and reverted to use drevops script for provisioning. --- .docker/entrypoints/cli/03-provision-site.sh | 6 +++--- .github/workflows/build-deploy.yml | 21 ++++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.docker/entrypoints/cli/03-provision-site.sh b/.docker/entrypoints/cli/03-provision-site.sh index b9cf8b32f..623766f20 100755 --- a/.docker/entrypoints/cli/03-provision-site.sh +++ b/.docker/entrypoints/cli/03-provision-site.sh @@ -32,9 +32,9 @@ set -e # Delegate Drupal provisioning to the Quant-aware script. The standard # DrevOps provision script is not compatible with Quant Cloud because it relies # on Lagoon-specific tooling (e.g., rsync to Lagoon SSH). -if [ -x "./scripts/quant/provision-quant.sh" ]; then - ./scripts/quant/provision-quant.sh +if [ -x "./scripts/drevops/provision.sh" ]; then + ./scripts/drevops/provision.sh else - echo "Quant provisioning script missing or not executable." >&2 + echo "Drevops provisioning script missing or not executable." >&2 exit 1 fi diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 75474b1d9..6e6ea8f39 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -10,6 +10,7 @@ name: Build and Push civictheme-monorepo-drupal to Quant Cloud - release/* - hotfix/* - feature/editorial-* + - project/quant-provision tags: - '*' @@ -37,9 +38,12 @@ jobs: quant_application: civictheme-monorepo-drupal master_branch_override: main - - name: Override outputs for quant-cloud-migration branch + - name: Override outputs for special branches id: override-outputs run: |- + # Default: do not skip database sync + skip_db_sync="false" + # Override outputs for quant-cloud-migration branch to treat it as production if [[ "${{ github.ref }}" == "refs/heads/quant-cloud-migration" ]]; then echo "image_suffix=-latest" >> $GITHUB_OUTPUT @@ -48,6 +52,17 @@ jobs: echo "environment_name=production" >> $GITHUB_OUTPUT echo "environment_exists=true" >> $GITHUB_OUTPUT echo "Overriding outputs for quant-cloud-migration branch: using -latest suffix and production environment" + # Override for project/quant-provision branch to skip database sync (fresh install from static content) + elif [[ "${{ github.ref }}" == "refs/heads/project/quant-provision" ]]; then + echo "image_suffix=${{ steps.init.outputs.image_suffix }}" >> $GITHUB_OUTPUT + suffix="${{ steps.init.outputs.image_suffix }}" + clean_suffix="${suffix#-}" + echo "image_suffix_clean=$clean_suffix" >> $GITHUB_OUTPUT + echo "is_production=false" >> $GITHUB_OUTPUT + echo "environment_name=${{ steps.init.outputs.environment_name }}" >> $GITHUB_OUTPUT + echo "environment_exists=${{ steps.init.outputs.environment_exists }}" >> $GITHUB_OUTPUT + skip_db_sync="true" + echo "Overriding outputs for project/quant-provision branch: skipping database sync" else # Use the original action outputs echo "image_suffix=${{ steps.init.outputs.image_suffix }}" >> $GITHUB_OUTPUT @@ -60,6 +75,8 @@ jobs: echo "environment_exists=${{ steps.init.outputs.environment_exists }}" >> $GITHUB_OUTPUT fi + echo "skip_db_sync=$skip_db_sync" >> $GITHUB_OUTPUT + - name: Build and push cli image uses: docker/build-push-action@v5 with: @@ -121,7 +138,7 @@ jobs: - name: Sync database from production to new environment if: ${{ !startsWith(github.ref, 'refs/tags/') && steps.override-outputs.outputs.environment_exists == 'false' && steps.override-outputs.outputs.environment_name - != 'production' }} + != 'production' && steps.override-outputs.outputs.skip_db_sync != 'true' }} uses: quantcdn/quant-cloud-environment-sync-action@v1.0.0 with: api_key: ${{ secrets.QUANT_API_KEY }} From 7a6f8a7200626d39c6beedb6756b261c460f9f5f Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 12:44:36 +1100 Subject: [PATCH 02/12] Updated composer. --- composer.json | 3 --- composer.lock | 18 +++++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 950c7fccc..c89823069 100644 --- a/composer.json +++ b/composer.json @@ -185,9 +185,6 @@ "drupal/sdc_devel": { "Change visibility of the rules constants in TwigValidatorRulePluginBase - https://www.drupal.org/project/sdc_devel/issues/3517321": "./patches/modules/sdc_devel/3517321--updated-visibility-of-rule-constants.patch", "Remove check for use of default filter in boolean filter": "./patches/modules/sdc_devel/remove-boolean-filter-default.patch" - }, - "drupal/simple_sitemap": { - "Error on installing / enabling simple_sitemap in D11: https://www.drupal.org/project/simple_sitemap/issues/3507718": "./patches/modules/simple_sitemap/fix-error-on-install.patch" } }, "preserve-paths": [ diff --git a/composer.lock b/composer.lock index 593ec0014..4497662da 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ef3ae12a7198da6816ba804f546c0e7c", + "content-hash": "8f3030211d9799c86ed573efa6c07657", "packages": [ { "name": "asm89/stack-cors", @@ -3090,20 +3090,20 @@ }, { "name": "drupal/simple_sitemap", - "version": "4.2.2", + "version": "4.2.3", "source": { "type": "git", "url": "https://git.drupalcode.org/project/simple_sitemap.git", - "reference": "4.2.2" + "reference": "4.2.3" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/simple_sitemap-4.2.2.zip", - "reference": "4.2.2", - "shasum": "1f9c9197d37450fb347a4fa3f10191f5f4b5ef13" + "url": "https://ftp.drupal.org/files/projects/simple_sitemap-4.2.3.zip", + "reference": "4.2.3", + "shasum": "08e87178a35fe2a89202d2423f3de1656e1e814a" }, "require": { - "drupal/core": "^10.2 || ^11", + "drupal/core": "^10.3 || ^11", "ext-xmlwriter": "*" }, "conflict": { @@ -3115,8 +3115,8 @@ "type": "drupal-module", "extra": { "drupal": { - "version": "4.2.2", - "datestamp": "1750876597", + "version": "4.2.3", + "datestamp": "1764147268", "security-coverage": { "status": "covered", "message": "Covered by Drupal's security advisory policy" From fd469ab62db1e0166f379273f841a7962303863c Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 13:45:43 +1100 Subject: [PATCH 03/12] Change drush location. --- scripts/drevops/provision.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/drevops/provision.sh b/scripts/drevops/provision.sh index 5e0a0ae11..4aa551049 100755 --- a/scripts/drevops/provision.sh +++ b/scripts/drevops/provision.sh @@ -72,7 +72,13 @@ fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 # @formatter:on yesno() { [ "${1}" = "1" ] && echo "Yes" || echo "No"; } -drush() { ./vendor/bin/drush -y "$@"; } +drush() { + if [ -n "${drush_uri}" ]; then + ./vendor/bin/drush -y --uri="${drush_uri}" "$@" + else + ./vendor/bin/drush -y "$@" + fi +} info "Started site provisioning." From ab203b5915fedada21852696147339512074ac36 Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 13:59:02 +1100 Subject: [PATCH 04/12] Added drush_uri. --- scripts/drevops/provision.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/drevops/provision.sh b/scripts/drevops/provision.sh index 4aa551049..0281ca3f7 100755 --- a/scripts/drevops/provision.sh +++ b/scripts/drevops/provision.sh @@ -72,6 +72,25 @@ fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 # @formatter:on yesno() { [ "${1}" = "1" ] && echo "Yes" || echo "No"; } + +# Prepare Drush URI using QUANT_ROUTE when available. +drush_uri="" +if [ -v QUANT_ROUTE ] && [ -n "${QUANT_ROUTE}" ]; then + case "${QUANT_ROUTE}" in + http://*|https://*) + drush_uri="${QUANT_ROUTE%/}" + info "Using QUANT_ROUTE for Drush URI: ${drush_uri}" + ;; + *) + note "QUANT_ROUTE is set but is not a full URL. Drush will fall back to the default site context." + ;; + esac +elif [ -v QUANT_ROUTE ]; then + note "QUANT_ROUTE is defined but empty. Drush will fall back to the default site context." +else + note "QUANT_ROUTE not defined. Drush will fall back to the default site context." +fi + drush() { if [ -n "${drush_uri}" ]; then ./vendor/bin/drush -y --uri="${drush_uri}" "$@" From 3485f6aa07c2fbf70fe252fb4df6825707312f63 Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 14:30:35 +1100 Subject: [PATCH 05/12] Move the fix drush up stack to pre-deployment. --- .../cli/{99-fix-drush-config.sh => 02-fix-drush-config.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .docker/entrypoints/cli/{99-fix-drush-config.sh => 02-fix-drush-config.sh} (100%) diff --git a/.docker/entrypoints/cli/99-fix-drush-config.sh b/.docker/entrypoints/cli/02-fix-drush-config.sh similarity index 100% rename from .docker/entrypoints/cli/99-fix-drush-config.sh rename to .docker/entrypoints/cli/02-fix-drush-config.sh From 4c9c75ebc0aab499e312eac7fea66ffcf1ef07f2 Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 14:32:03 +1100 Subject: [PATCH 06/12] Uncommented provision script. --- .docker/entrypoints/cli/03-provision-site.sh | 36 ++++++-------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/.docker/entrypoints/cli/03-provision-site.sh b/.docker/entrypoints/cli/03-provision-site.sh index 623766f20..047fd8776 100755 --- a/.docker/entrypoints/cli/03-provision-site.sh +++ b/.docker/entrypoints/cli/03-provision-site.sh @@ -5,13 +5,13 @@ set -e # Generated from .lagoon.yml # COMMENTED OUT: This script contains rsync commands that won't work in Quant Cloud -# if [ "$LAGOON_ENVIRONMENT_TYPE" = "production" ] || [ "$LAGOON_GIT_BRANCH" = "${DREVOPS_LAGOON_PRODUCTION_BRANCH:-main}" ]; then -# echo "==> Running in PRODUCTION environment." -# # Never unblock admin user in production. -# export DRUPAL_UNBLOCK_ADMIN=0 -# # Never sanitize DB in production. -# export DREVOPS_PROVISION_SANITIZE_DB_SKIP=1 -# fi + if [ "$LAGOON_ENVIRONMENT_TYPE" = "production" ] || [ "$LAGOON_GIT_BRANCH" = "${DREVOPS_LAGOON_PRODUCTION_BRANCH:-main}" ]; then + echo "==> Running in PRODUCTION environment." + # Never unblock admin user in production. + export DRUPAL_UNBLOCK_ADMIN=0 + # Never sanitize DB in production. + export DREVOPS_PROVISION_SANITIZE_DB_SKIP=1 + fi # # # Deployments from UI are not able to bypass the value of # # DREVOPS_PROVISION_OVERRIDE_DB set by the deploy-lagoon.sh @@ -20,21 +20,7 @@ set -e # # @see https://github.com/uselagoon/lagoon/issues/1922 # # Explicitly set DB overwrite flag to the value from .env file for # # deployments from the profile. -# if [ "${DREVOPS_PROVISION_USE_PROFILE}" = "1" ]; then -# export DREVOPS_PROVISION_OVERRIDE_DB="$(cat .env | grep ^DREVOPS_PROVISION_OVERRIDE_DB | cut -c31-)" -# fi -# ./scripts/drevops/provision.sh - -# NOTE: This provision script has been disabled because: -# - rsync commands try to connect to Lagoon SSH which is not available in Quant Cloud -# - Use DREVOPS_PROVISION_SKIP=1 environment variable to skip provision steps - -# Delegate Drupal provisioning to the Quant-aware script. The standard -# DrevOps provision script is not compatible with Quant Cloud because it relies -# on Lagoon-specific tooling (e.g., rsync to Lagoon SSH). -if [ -x "./scripts/drevops/provision.sh" ]; then - ./scripts/drevops/provision.sh -else - echo "Drevops provisioning script missing or not executable." >&2 - exit 1 -fi + if [ "${DREVOPS_PROVISION_USE_PROFILE}" = "1" ]; then + export DREVOPS_PROVISION_OVERRIDE_DB="$(cat .env | grep ^DREVOPS_PROVISION_OVERRIDE_DB | cut -c31-)" + fi + ./scripts/drevops/provision.sh From e7de9bcc7fb4155604cfc68004c5fbfa833003ec Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 14:52:30 +1100 Subject: [PATCH 07/12] Revert drush change back in drevops provision script. --- scripts/drevops/provision.sh | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/scripts/drevops/provision.sh b/scripts/drevops/provision.sh index 0281ca3f7..5e0a0ae11 100755 --- a/scripts/drevops/provision.sh +++ b/scripts/drevops/provision.sh @@ -72,32 +72,7 @@ fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\03 # @formatter:on yesno() { [ "${1}" = "1" ] && echo "Yes" || echo "No"; } - -# Prepare Drush URI using QUANT_ROUTE when available. -drush_uri="" -if [ -v QUANT_ROUTE ] && [ -n "${QUANT_ROUTE}" ]; then - case "${QUANT_ROUTE}" in - http://*|https://*) - drush_uri="${QUANT_ROUTE%/}" - info "Using QUANT_ROUTE for Drush URI: ${drush_uri}" - ;; - *) - note "QUANT_ROUTE is set but is not a full URL. Drush will fall back to the default site context." - ;; - esac -elif [ -v QUANT_ROUTE ]; then - note "QUANT_ROUTE is defined but empty. Drush will fall back to the default site context." -else - note "QUANT_ROUTE not defined. Drush will fall back to the default site context." -fi - -drush() { - if [ -n "${drush_uri}" ]; then - ./vendor/bin/drush -y --uri="${drush_uri}" "$@" - else - ./vendor/bin/drush -y "$@" - fi -} +drush() { ./vendor/bin/drush -y "$@"; } info "Started site provisioning." From 3914052e2eaabb34ea76358aa76014841ba98951 Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 16:38:36 +1100 Subject: [PATCH 08/12] Increased memory limit for php processes. --- .docker/cli.dockerfile | 3 +++ .docker/config/php/zzz-memory.ini | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 .docker/config/php/zzz-memory.ini diff --git a/.docker/cli.dockerfile b/.docker/cli.dockerfile index 51c057940..1f1a93217 100644 --- a/.docker/cli.dockerfile +++ b/.docker/cli.dockerfile @@ -111,3 +111,6 @@ RUN cd /app/web/themes/contrib/civictheme \ RUN npm --prefix web/themes/custom/civictheme_demo install --no-audit --no-progress --unsafe-perm \ && cd /app/web/themes/custom/civictheme_demo && npm run build COPY .docker/entrypoints/cli/* /quant-entrypoint.d/ + +# Custom PHP configuration. +COPY .docker/config/php/*.ini /usr/local/etc/php/conf.d/ diff --git a/.docker/config/php/zzz-memory.ini b/.docker/config/php/zzz-memory.ini new file mode 100644 index 000000000..0abfe49df --- /dev/null +++ b/.docker/config/php/zzz-memory.ini @@ -0,0 +1,2 @@ +; Custom PHP memory limit +memory_limit = 768M From 74349704fc444ff71061f3e607450c5244c23f39 Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 17:00:36 +1100 Subject: [PATCH 09/12] Cleanup. --- ...t.sh => 03-notify-about-pre-deployment.sh} | 0 ...provision-site.sh => 04-provision-site.sh} | 15 +- ...sh => 05-send-deployment-notifications.sh} | 0 scripts/quant/provision-quant.sh | 224 ------------------ 4 files changed, 7 insertions(+), 232 deletions(-) rename .docker/entrypoints/cli/{02-notify-about-pre-deployment.sh => 03-notify-about-pre-deployment.sh} (100%) rename .docker/entrypoints/cli/{03-provision-site.sh => 04-provision-site.sh} (54%) rename .docker/entrypoints/cli/{04-send-deployment-notifications.sh => 05-send-deployment-notifications.sh} (100%) delete mode 100755 scripts/quant/provision-quant.sh diff --git a/.docker/entrypoints/cli/02-notify-about-pre-deployment.sh b/.docker/entrypoints/cli/03-notify-about-pre-deployment.sh similarity index 100% rename from .docker/entrypoints/cli/02-notify-about-pre-deployment.sh rename to .docker/entrypoints/cli/03-notify-about-pre-deployment.sh diff --git a/.docker/entrypoints/cli/03-provision-site.sh b/.docker/entrypoints/cli/04-provision-site.sh similarity index 54% rename from .docker/entrypoints/cli/03-provision-site.sh rename to .docker/entrypoints/cli/04-provision-site.sh index 047fd8776..28882ab6c 100755 --- a/.docker/entrypoints/cli/03-provision-site.sh +++ b/.docker/entrypoints/cli/04-provision-site.sh @@ -3,7 +3,6 @@ set -e # Post-rollout task: Provision site # Generated from .lagoon.yml -# COMMENTED OUT: This script contains rsync commands that won't work in Quant Cloud if [ "$LAGOON_ENVIRONMENT_TYPE" = "production" ] || [ "$LAGOON_GIT_BRANCH" = "${DREVOPS_LAGOON_PRODUCTION_BRANCH:-main}" ]; then echo "==> Running in PRODUCTION environment." @@ -13,13 +12,13 @@ set -e export DREVOPS_PROVISION_SANITIZE_DB_SKIP=1 fi # -# # Deployments from UI are not able to bypass the value of -# # DREVOPS_PROVISION_OVERRIDE_DB set by the deploy-lagoon.sh -# # during previous deployments (it sets value to '0' to mitigate Lagoon bug -# # where environment variables cannot be deleted and have to be set to a value). -# # @see https://github.com/uselagoon/lagoon/issues/1922 -# # Explicitly set DB overwrite flag to the value from .env file for -# # deployments from the profile. +# Deployments from UI are not able to bypass the value of +# DREVOPS_PROVISION_OVERRIDE_DB set by the deploy-lagoon.sh +# during previous deployments (it sets value to '0' to mitigate Lagoon bug +# where environment variables cannot be deleted and have to be set to a value). +# @see https://github.com/uselagoon/lagoon/issues/1922 +# Explicitly set DB overwrite flag to the value from .env file for +# deployments from the profile. if [ "${DREVOPS_PROVISION_USE_PROFILE}" = "1" ]; then export DREVOPS_PROVISION_OVERRIDE_DB="$(cat .env | grep ^DREVOPS_PROVISION_OVERRIDE_DB | cut -c31-)" fi diff --git a/.docker/entrypoints/cli/04-send-deployment-notifications.sh b/.docker/entrypoints/cli/05-send-deployment-notifications.sh similarity index 100% rename from .docker/entrypoints/cli/04-send-deployment-notifications.sh rename to .docker/entrypoints/cli/05-send-deployment-notifications.sh diff --git a/scripts/quant/provision-quant.sh b/scripts/quant/provision-quant.sh deleted file mode 100755 index 3ddb56b7b..000000000 --- a/scripts/quant/provision-quant.sh +++ /dev/null @@ -1,224 +0,0 @@ -#!/usr/bin/env bash -## -# Run Drupal provisioning steps tailored for Quant Cloud deployments. -# -# This script runs essential deployment tasks (database updates, configuration -# import, and cache rebuild) while ensuring Drush commands execute against the -# correct Quant site URL. -# -# shellcheck disable=SC1091 - -# Load project environment variables while preserving current exports. -t=$(mktemp) && export -p >"${t}" && set -a && . ./.env && if [ -f ./.env.local ]; then . ./.env.local; fi && set +a && . "${t}" && rm "${t}" && unset t - -set -eu -[ "${DREVOPS_DEBUG-}" = "1" ] && set -x - -# Helper output functions. -note() { printf " %s\n" "${1}"; } -info() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[34m[INFO] %s\033[0m\n" "${1}" || printf "[INFO] %s\n" "${1}"; } -pass() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[32m[ OK ] %s\033[0m\n" "${1}" || printf "[ OK ] %s\n" "${1}"; } -fail() { [ "${TERM:-}" != "dumb" ] && tput colors >/dev/null 2>&1 && printf "\033[31m[FAIL] %s\033[0m\n" "${1}" || printf "[FAIL] %s\n" "${1}"; } - -DREVOPS_PROVISION_SKIP="${DREVOPS_PROVISION_SKIP:-0}" - -if [ "${DREVOPS_PROVISION_SKIP}" = "1" ]; then - pass "Skipped Quant provisioning because DREVOPS_PROVISION_SKIP=1." - exit 0 -fi - -# Detect Quant Cloud environment (variables may be set but empty). -has_quant_environment=0 -if [ -v QUANT_ENV_TYPE ] || [ -v QUANT_ENV_NAME ] || [ -v QUANT_APP_NAME ]; then - has_quant_environment=1 -fi - -if [ "${has_quant_environment}" -ne 1 ]; then - info "Quant Cloud environment not detected; nothing to do." - exit 0 -fi - -info "Detected Quant Cloud environment." - -# Prepare Drush URI using QUANT_ROUTE when available. -drush_uri="" -if [ -v QUANT_ROUTE ] && [ -n "${QUANT_ROUTE}" ]; then - case "${QUANT_ROUTE}" in - http://*|https://*) - drush_uri="${QUANT_ROUTE%/}" - info "Using QUANT_ROUTE for Drush URI: ${drush_uri}" - ;; - *) - note "QUANT_ROUTE is set but is not a full URL. Drush will fall back to the default site context." - ;; - esac -elif [ -v QUANT_ROUTE ]; then - note "QUANT_ROUTE is defined but empty. Drush will fall back to the default site context." -else - note "QUANT_ROUTE not defined. Drush will fall back to the default site context." -fi - -drush_quant() { - if [ -n "${drush_uri}" ]; then - ./vendor/bin/drush -y --uri="${drush_uri}" "$@" - else - ./vendor/bin/drush -y "$@" - fi -} - -# Check whether a comma or space separated list contains the provided token. -contains_token() { - local needle="$1" - local haystack="$2" - local token trimmed - - if [ -z "${needle}" ] || [ -z "${haystack}" ]; then - return 1 - fi - - for token in ${haystack//,/ }; do - # Remove any whitespace characters from the token to allow comma-separated - # or space-separated lists. - trimmed="${token//[[:space:]]/}" - if [ -n "${trimmed}" ] && [ "${needle}" = "${trimmed}" ]; then - return 0 - fi - done - - return 1 -} - -# Resolve the configuration source directory for the current Quant environment. -resolve_config_source() { - local env_type="$1" - local env_name="$2" - local source="${default_config_dir}" - - # Normalise case and trim accidental whitespace. - env_type="${env_type,,}" - env_name="${env_name,,}" - - # Exclude these names from mapping to development by default. - # By convention, Quant won't use these, but keep guard-rails in place. - local exclude_from_dev="${QUANT_CONFIG_ENV_NAMES_EXCLUDE_FROM_DEVELOPMENT:-ci,local}" - - # The rule that determined the mapping; used for logging. - CONFIG_SOURCE_RULE="default" - - # 1) Explicit production mapping takes precedence. - if contains_token "${env_type}" "${production_types}" || contains_token "${env_name}" "${production_names}"; then - source="${production_config_dir}" - CONFIG_SOURCE_RULE="production" - - # 2) Explicit test mapping by name next. - elif contains_token "${env_name}" "${test_names}"; then - source="${test_config_dir}" - CONFIG_SOURCE_RULE="test" - - # 3) Explicit development mapping by type/name. - elif contains_token "${env_type}" "${development_types}" || contains_token "${env_name}" "${development_names}"; then - source="${development_config_dir}" - CONFIG_SOURCE_RULE="development-explicit" - - # 4) Fallback rule: anything not 'ci' or 'local' is development. - elif ! contains_token "${env_name}" "${exclude_from_dev}"; then - source="${development_config_dir}" - CONFIG_SOURCE_RULE="development-fallback" - else - CONFIG_SOURCE_RULE="excluded-from-development" - fi - - # Print both values so caller can capture without relying on subshell state. - printf '%s\n%s' "${source}" "${CONFIG_SOURCE_RULE}" -} - -# Determine if the provided configuration directory exists and contains YAML -# files. Partial or full imports should be skipped when the directory is empty -# to avoid Drush failures. -config_dir_has_files() { - local dir="$1" - - if [ ! -d "${dir}" ]; then - return 1 - fi - - if find "${dir}" -type f -name '*.yml' -print -quit | grep -q .; then - return 0 - fi - - return 1 -} - -info "Running Drupal database updates." -drush_quant updatedb || { fail "Database updates failed."; exit 1; } -pass "Database updates complete." - -default_config_dir="${QUANT_CONFIG_DIR_DEFAULT:-config/default}" -base_config_available=0 - -if config_dir_has_files "${default_config_dir}"; then - info "Importing Drupal configuration from ${default_config_dir}." - drush_quant config:import || { fail "Configuration import failed."; exit 1; } - pass "Configuration import complete." - base_config_available=1 -else - note "Configuration directory ${default_config_dir} is missing or empty; skipping all configuration imports." -fi - -# Apply environment-specific configuration overlays only when base configuration -# exists and has been imported. -quant_env_type="${QUANT_ENV_TYPE:-}" -quant_env_name="${QUANT_ENV_NAME:-}" - -if [ "${base_config_available}" -eq 1 ] && { [ -n "${quant_env_type}" ] || [ -n "${quant_env_name}" ]; }; then - production_config_dir="${QUANT_CONFIG_DIR_PRODUCTION:-${default_config_dir}}" - development_config_dir="${QUANT_CONFIG_DIR_DEVELOPMENT:-config/dev}" - test_config_dir="${QUANT_CONFIG_DIR_TEST:-config/test}" - - production_types="${QUANT_CONFIG_ENV_TYPES_PRODUCTION:-production}" - development_types="${QUANT_CONFIG_ENV_TYPES_DEVELOPMENT:-development}" - - production_names="${QUANT_CONFIG_ENV_NAMES_PRODUCTION:-production}" - development_names="${QUANT_CONFIG_ENV_NAMES_DEVELOPMENT:-develop}" - # Default to recognise both master and uat as test environments. - test_names="${QUANT_CONFIG_ENV_NAMES_TEST:-master,uat}" - - # Capture both the resolved source and the rule without leaking subshell state. - read -r config_source CONFIG_SOURCE_RULE <<<"$(resolve_config_source "${quant_env_type}" "${quant_env_name}")" - - # Always pass an absolute path to Drush to avoid CWD/docroot ambiguity. - if [ -n "${config_source}" ] && [ "${config_source#/}" = "${config_source}" ]; then - # Convert relative path to absolute from repository root. - config_source="$(pwd -P)/${config_source#./}" - fi - - info "Resolved config overlay mapping: type='${quant_env_type:-unset}', name='${quant_env_name:-unset}' -> '${config_source}' (rule: ${CONFIG_SOURCE_RULE:-default})." - - if [ -z "${config_source}" ]; then - note "Environment-specific configuration mapping did not resolve to a directory; skipping partial import." - elif [ "${config_source}" = "${default_config_dir}" ]; then - note "Environment-specific configuration maps to ${config_source} (rule: ${CONFIG_SOURCE_RULE:-default}); base configuration already imported." - elif config_dir_has_files "${config_source}"; then - message_suffix="" - if [ -n "${quant_env_name}" ]; then - message_suffix=", name: ${quant_env_name}" - fi - info "Importing environment-specific configuration from ${config_source} (type: ${quant_env_type:-unset}${message_suffix})." - drush_quant config:import --partial --source="${config_source}" || { - fail "Environment-specific configuration import failed."; exit 1; - } - pass "Environment-specific configuration import complete." - else - note "Environment-specific configuration directory ${config_source} is missing or empty; skipping partial import." - fi -elif [ "${base_config_available}" -eq 0 ]; then - note "Skipping environment-specific configuration import because base configuration is unavailable." -else - note "QUANT environment variables not provided; skipping environment-specific configuration import." -fi - -info "Rebuilding Drupal caches." -drush_quant cache:rebuild || { fail "Cache rebuild failed."; exit 1; } -pass "Cache rebuild complete." - -pass "Quant Cloud provisioning finished successfully." From b74e95088b536102486331e9dae5fc76b838c53c Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 17:04:15 +1100 Subject: [PATCH 10/12] Remove sync database workflow. --- .github/workflows/build-deploy.yml | 57 +++++------------------------- 1 file changed, 8 insertions(+), 49 deletions(-) diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 6e6ea8f39..d83e7cbaa 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -41,41 +41,15 @@ jobs: - name: Override outputs for special branches id: override-outputs run: |- - # Default: do not skip database sync - skip_db_sync="false" + echo "image_suffix=${{ steps.init.outputs.image_suffix }}" >> $GITHUB_OUTPUT + # Remove leading hyphen from image_suffix for image_suffix parameter + suffix="${{ steps.init.outputs.image_suffix }}" + clean_suffix="${suffix#-}" + echo "image_suffix_clean=$clean_suffix" >> $GITHUB_OUTPUT + echo "is_production=${{ steps.init.outputs.is_production }}" >> $GITHUB_OUTPUT + echo "environment_name=${{ steps.init.outputs.environment_name }}" >> $GITHUB_OUTPUT + echo "environment_exists=${{ steps.init.outputs.environment_exists }}" >> $GITHUB_OUTPUT - # Override outputs for quant-cloud-migration branch to treat it as production - if [[ "${{ github.ref }}" == "refs/heads/quant-cloud-migration" ]]; then - echo "image_suffix=-latest" >> $GITHUB_OUTPUT - echo "image_suffix_clean=latest" >> $GITHUB_OUTPUT - echo "is_production=true" >> $GITHUB_OUTPUT - echo "environment_name=production" >> $GITHUB_OUTPUT - echo "environment_exists=true" >> $GITHUB_OUTPUT - echo "Overriding outputs for quant-cloud-migration branch: using -latest suffix and production environment" - # Override for project/quant-provision branch to skip database sync (fresh install from static content) - elif [[ "${{ github.ref }}" == "refs/heads/project/quant-provision" ]]; then - echo "image_suffix=${{ steps.init.outputs.image_suffix }}" >> $GITHUB_OUTPUT - suffix="${{ steps.init.outputs.image_suffix }}" - clean_suffix="${suffix#-}" - echo "image_suffix_clean=$clean_suffix" >> $GITHUB_OUTPUT - echo "is_production=false" >> $GITHUB_OUTPUT - echo "environment_name=${{ steps.init.outputs.environment_name }}" >> $GITHUB_OUTPUT - echo "environment_exists=${{ steps.init.outputs.environment_exists }}" >> $GITHUB_OUTPUT - skip_db_sync="true" - echo "Overriding outputs for project/quant-provision branch: skipping database sync" - else - # Use the original action outputs - echo "image_suffix=${{ steps.init.outputs.image_suffix }}" >> $GITHUB_OUTPUT - # Remove leading hyphen from image_suffix for image_suffix parameter - suffix="${{ steps.init.outputs.image_suffix }}" - clean_suffix="${suffix#-}" - echo "image_suffix_clean=$clean_suffix" >> $GITHUB_OUTPUT - echo "is_production=${{ steps.init.outputs.is_production }}" >> $GITHUB_OUTPUT - echo "environment_name=${{ steps.init.outputs.environment_name }}" >> $GITHUB_OUTPUT - echo "environment_exists=${{ steps.init.outputs.environment_exists }}" >> $GITHUB_OUTPUT - fi - - echo "skip_db_sync=$skip_db_sync" >> $GITHUB_OUTPUT - name: Build and push cli image uses: docker/build-push-action@v5 @@ -136,21 +110,6 @@ jobs: from_environment: production image_suffix: ${{ steps.override-outputs.outputs.image_suffix_clean }} - - name: Sync database from production to new environment - if: ${{ !startsWith(github.ref, 'refs/tags/') && steps.override-outputs.outputs.environment_exists == 'false' && steps.override-outputs.outputs.environment_name - != 'production' && steps.override-outputs.outputs.skip_db_sync != 'true' }} - uses: quantcdn/quant-cloud-environment-sync-action@v1.0.0 - with: - api_key: ${{ secrets.QUANT_API_KEY }} - organization: ${{ secrets.QUANT_ORGANIZATION }} - app_name: ${{ steps.init.outputs.quant_application }} - environment_name: ${{ steps.override-outputs.outputs.environment_name }} - source: production - type: database - wait: true - wait_interval: 10 - max_retries: 30 - - name: Redeploy existing environment if: ${{ !startsWith(github.ref, 'refs/tags/') && steps.override-outputs.outputs.environment_exists == 'true' }} uses: quantcdn/quant-cloud-environment-state-action@v1 From 3020b9e37cbcf401eb827f420048622192b9fd0b Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 18:16:46 +1100 Subject: [PATCH 11/12] Remove lagoon deploy type. --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index afa1e9432..ffa48c08e 100644 --- a/.env +++ b/.env @@ -124,7 +124,7 @@ LAGOON_PROJECT=civictheme-monorepo-drupal # `artifact`,`docker`, `webhook`, `lagoon`. # # See https://docs.drevops.com/workflows/deploy -DREVOPS_DEPLOY_TYPES=lagoon +DREVOPS_DEPLOY_TYPES=none # Dedicated branch to identify the production environment. DREVOPS_LAGOON_PRODUCTION_BRANCH=main From f8710b0b13dbd5dc237d1b06f3a64799c44dce5b Mon Sep 17 00:00:00 2001 From: rgaunt Date: Thu, 27 Nov 2025 18:24:39 +1100 Subject: [PATCH 12/12] Remove deploy job from circleci. --- .circleci/config.yml | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dc8610ed8..47db6e0cf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -449,27 +449,6 @@ jobs: DREVOPS_EXPORT_CODE_DIR: '/tmp/workspace/code_unused' <<: *job-build - # Deploy primary branches. - deploy: &job_deploy - <<: *runner_config - steps: - - attach_workspace: - at: /tmp/workspace - - add_ssh_keys: - fingerprints: - - *deploy_ssh_fingerprint - - checkout - - *step_process_codebase - - run: - command: | - DREVOPS_DEPLOY_BRANCH="$CIRCLE_BRANCH" \ - DREVOPS_DEPLOY_PR="$(echo $CIRCLE_PULL_REQUEST | cut -d'/' -f 7)" \ - DREVOPS_DEPLOY_PR_HEAD=$CIRCLE_SHA1 \ - ./scripts/drevops/deploy.sh - no_output_timeout: 30m - - store_artifacts: - path: *artifacts - # Deploy artifact. deploy_artifact: <<: *runner_config