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:
                name: Prepare gitignore
                command: |
                  rm .gitignore
             - run: composer -n install --optimize-autoloader --ignore-platform-reqs --no-devmv .gitignore-deploy .gitignore
            - run: composer prepare-for-pantheon
            # Install node modules and build theme.
            - run:
                name: Node Install
                command: npm it
            # Cache node_modules so the packages don't need to be redownloaded next time.
            - save_cache:
                name: Save Node Cache
                key: drupal-node-{{ checksum "package-lock.json" }}
                paths:
                  - node_modules
            # Cache composer so the packages don't need to be redownloaded next time.
            - save_cache:
                name: Save Composer Cache
                key: drupal-composer-v1-{{ checksum "composer.lock" }}
                paths:
                  - ~/.composer/cache
          filters:
            branches:
              only:
                - master
      - pantheon/push:
          checkout: false
          terminus_clone_env: "dev"
          pre-steps:
            - checkout
            - restore_cache:
                name: Restore Node Cache
                keys:
                  - drupal-node-{{ checksum "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
            - run:
                name: Node Install
                command: npm it
            # Cache node_modules so the packages don't need to be redownloaded next time.
            - save_cache:
                name: Save Node Cache
                key: drupal-node-{{ checksum "package-lock.json" }}
                paths:
                  - node_modules
            # Cache composer so the packages don't need to be redownloaded next time.
            - save_cache:
                name: Save Composer Cache
                key: drupal-composer-v1-{{ checksum "composer.lock" }}
                paths:
                  - ~/.composer/cache
          filters:
            branches:
              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"

...

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.