Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
  // 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

Code Block
languagephp
use Symfony\Component\Finder\Finder;

Make sure to include it inside the class e. g. prior to the last }

...

Code Block
languageyaml
version: 2.1
workflows:
  version: 2
  build_and_test:
    jobs:
      - pantheon/push:
          checkout: false
          clone_content: false
          pre-steps:
            - checkout
            - restore_cache:
                name: Restore Node Cache
                keys:
                  - drupal-node-{{"package-lock.json" }}
                  # Fallback to most recent build if this exact config hasn't been installed before.
                  - drupal-node-
            # Restore composer packages if they have been previously downloaded and cached.
            - restore_cache:
                name: Restore Composer Cache
                keys:
                  - drupal-composer-v1-{{ checksum "composer.lock" }}
                  # Fallback to most recent build if this exact config hasn't been installed before.
                  - drupal-composer-v1-
            - run: composer -n install --optimize-autoloader --ignore-platform-reqs --no-dev
            - run:
 composer prepare-for-pantheon             # Installname: nodePrepare modulesgitignore
and build theme.             - runcommand: |
               name: Node Install rm .gitignore
              command: npm it      mv .gitignore-deploy .gitignore
            - run: composer prepare-for-pantheon
      # Cache node_modules so the packages don't# needInstall tonode bemodules redownloadedand nextbuild timetheme.
            - save_cacherun:
                name: Save Node CacheInstall
                keycommand: drupal-node-{{ checksum "package-lock.json" }}npm it
            # Cache node_modules so the packages paths:don't need to be redownloaded next time.
            - nodesave_modulescache:
             # Cache composer soname: theSave packagesNode don'tCache
need to be redownloaded next time.           key: drupal-node-{{ checksum "package- save_cache:lock.json" }}
                namepaths: Save
Composer Cache                 key: drupal-composer-v1-{{ checksum "composer.lock" }}node_modules
            # Cache composer so the packages paths:don't need to be redownloaded next time.
            - ~/.composer/cachesave_cache:
          filters:      name: Save Composer Cache
   branches:             key:  only:
drupal-composer-v1-{{ checksum "composer.lock" }}
               - masterpaths:
      - pantheon/push:           checkout: false- ~/.composer/cache
          terminus_clone_envfilters:
 "dev"           pre-steps:branches:
              only:
  - checkout             - restore_cache:master
      - pantheon/push:
          namecheckout: Restorefalse
Node Cache         terminus_clone_env: "dev"
          keyspre-steps:
            - checkout
    - drupal-node-{{ checksum "package-lock.json" }}        - restore_cache:
                name: Restore Node Cache
   # Fallback to most recent build if this exact config hasn't been installed before.keys:
                  - drupal-node-{{ checksum "package-lock.json" }}
         # Restore composer packages if they have been previously downloaded# andFallback cached.to most recent build if this exact config hasn't been installed before.
 - restore_cache:                 name: Restore Composer Cache- drupal-node-
            # Restore composer packages if they have keys:been previously downloaded and cached.
              - drupal-composer-v1-{{ checksum "composer.lock" }}restore_cache:
                name: Restore Composer Cache
   # Fallback to most recent build if this exact config hasn't been installed before.keys:
                  - drupal-composer-v1-{{ checksum "composer.lock" }}
          - run: composer -n install --optimize-autoloader --ignore-platform-reqs --no-dev # Fallback to most recent build if this exact config hasn't been -installed run:before.
composer prepare-for-pantheon             - run:   - drupal-composer-v1-
            - namerun: Nodecomposer Install-n install --optimize-autoloader --ignore-platform-reqs --no-dev
            - commandrun: npm itcomposer prepare-for-pantheon
            #- Cacherun:
node_modules so the packages don't need to be redownloaded next time.      name: Node Install
    - save_cache:           command: npm it
   name: Save Node Cache      # Cache node_modules so the packages don't need to be redownloaded key: drupal-node-{{ checksum "package-lock.json" }}next time.
            - save_cache:
   paths:             name: Save Node Cache
  - node_modules             # Cache composer so the packages don't need to be redownloaded next time.key: drupal-node-{{ checksum "package-lock.json" }}
                paths:
   - save_cache:              - node_modules
 name: Save Composer Cache        # Cache composer so the packages don't need to key: drupal-composer-v1-{{ checksum "composer.lock" }}be redownloaded next time.
            - save_cache:
   paths:             name: Save Composer Cache
  - ~/.composer/cache           filters:  key: drupal-composer-v1-{{ checksum "composer.lock" }}
      branches:          paths:
    ignore:                 - master~/.composer/cache
          orbs:filters:
            pantheonbranches: pantheon-systems/pantheon@0.5.1

...


              ignore:
                - master

orbs:
  pantheon: pantheon-systems/pantheon@0.5.1

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.