fourkitchens / pots

Continuous Integration scripts for Drupal sites. Formerly Project CI.
GNU General Public License v3.0
1 stars 2 forks source link

Adjust config import to account for new splits #60

Open generalredneck opened 3 months ago

generalredneck commented 3 months ago

Based on this conversation,

The one additional thing that I find I have to do on every project is to create one more config split that is always on for everybody to hold the config_split configs for the local/dev/prod/whatever. I usually call it _splits and it allows me to override the drush-config-import script in pots, and add

 terminus -n drush "$P_SITE.$P_ENV" -- config-import --source="../config/_splits" --partial --yes
 terminus -n drush "$P_SITE.$P_ENV" -- cr

before the main config import. […] If you don’t do this, you run into problems deploying anything that changes the config splits themselves, as those changes are picked up during the config import step, but they won’t actually apply until config import is run a second time, which has caused me all sorts of problems in the past if you aren’t aware of it and adding manual steps to any deployment.

#!/bin/bash

set -eo pipefail

P_SITE="$1"
P_ENV="$2"

if [[ -z "$P_SITE" ]]; then
  P_SITE="$TERMINUS_SITE"
fi
if [[ -z "$P_ENV" ]]; then
  P_ENV="$TERMINUS_ENV"
fi

if [[ -z "$P_SITE" ]] || [[ -z "$P_ENV" ]]; then
  echo "Provide a site and enviornment."
  exit 1
fi

# Check for a system.site.yml file somewhere in the config directory.
if find ./config -name "system.site.yml" | grep "./config" -q ; then
  echo "Importing Configuration"
  terminus -n drush "$P_SITE.$P_ENV" -- config-import --source="../config/_splits" --partial --yes
  terminus -n drush "$P_SITE.$P_ENV" -- cr
  terminus -n drush "$P_SITE.$P_ENV" -- config-import --yes
else
  echo "We didn't import any configuration."
fi

# Clear Drupal cache
echo "Clearing Drupal cache again."
terminus -n drush "$P_SITE.$P_ENV" -- cr

if [[ $(terminus -n drush "$P_SITE.$P_ENV" -- cst) ]]
then
  echo "Config mismatch after config import. See report below."
  terminus -n drush "$P_SITE.$P_ENV" -- cst
  exit 1
fi
rigoucr commented 3 weeks ago

Top priority