Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust config import to account for new splits #37

Open
generalredneck opened this issue Jul 17, 2024 · 0 comments
Open

Adjust config import to account for new splits #37

generalredneck opened this issue Jul 17, 2024 · 0 comments

Comments

@generalredneck
Copy link
Collaborator

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.

Below is the implementation that was proposed for Pots

#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant