Pantheon orb setup for CI
Setup new site
Start your setup with Kalaboom and choose setup CI. If your site is Drupal 9 this is all you need to do. If your site is Drupal 8 you will need to take some manual steps.
Update composer.json
After Kalaboom is done you need to update your composer.json file to include the following in the scripts section of the file:
"prepare-for-pantheon": [
"DrupalProject\\composer\\ScriptHandler::prepareForPantheon"
]
Above drupal-scaffold
section include the following:
"prepare-for-pantheon": "DrupalProject\\composer\\ScriptHandler::prepareForPantheon",
Update ScriptHandler file for composer
Navigate to /scripts/composer/ScriptHandler
and update the file with the following:
// This is called by the QuickSilver deploy hook to convert from
// a 'lean' repository to a 'fat' repository. This should only be
// called when using this repository as a custom upstream, and
// updating it with `terminus composer <site>.<env> update`. This
// is not used in the GitHub PR workflow.
public static function prepareForPantheon()
{
// Get rid of any .git directories that Composer may have added.
// n.b. Ideally, there are none of these, as removing them may
// impair Composer's ability to update them later. However, leaving
// them in place prevents us from pushing to Pantheon.
$dirsToDelete = [];
$finder = new Finder();
foreach (
$finder
->directories()
->in(getcwd())
->ignoreDotFiles(false)
->ignoreVCS(false)
->depth('> 0')
->name('.git')
as $dir) {
$dirsToDelete[] = $dir;
}
$fs = new Filesystem();
$fs->remove($dirsToDelete);
// Fix up .gitignore: remove everything above the "::: cut :::" line
$gitignoreFile = getcwd() . '/.gitignore';
$gitignoreContents = file_get_contents($gitignoreFile);
$gitignoreContents = preg_replace('/.*::: cut :::*/s', '', $gitignoreContents);
file_put_contents($gitignoreFile, $gitignoreContents);
}
Make sure to update use statements and include
Make sure to include it inside the class e. g. prior to the last }
Setup theme processing in Drupal 8 and Drupal 9
Depending on how your theme is processed update node module cache and theme build commands, put them after composer install command in the CI.
Theme is compiled in theme folder
This snippet goes after composer restore cache command
After composer-prepare-for-pantheon include the following / update existing
Save node cache
Theme is compiled in the root with npm it
After composer-prepare-for-pantheon include the following / update existing
Save node cache
Setup existing site
Replace config.yml
in .circleci folder with something like the following:
Then perform updates for composer.json and ScriptHandler files as described above. Update theme compilation command as described above. Make sure your composer.json requires: "pantheon-systems/drupal-integrations": "^8.0"
Setup project in CircleCI
You will need to add three environment variables in the project. In CircleCI interface click on project settings → Environment Variables. Add the following variables:
TERMINUS_SITE
- Name of the site on pantheon (project name).
TERMINUS_SITE_NAME
- same as the above
TERMINUS_TOKEN
- machine token - generate deployment machine token through the dashboard on Pantheon.
Gotchas
If your site was deploying with a different CI you may want to add -v1-
to composer cache key as shown in the snippet above.