Skip to content

Instantly share code, notes, and snippets.

@amaisano
Last active April 29, 2019 13:14
Show Gist options
  • Save amaisano/709f0088080b046e0c7568d7b2e61336 to your computer and use it in GitHub Desktop.
Save amaisano/709f0088080b046e0c7568d7b2e61336 to your computer and use it in GitHub Desktop.
Adding Build Tools to an existing Pantheon Drupal Site

Disclaimer

This is very loose and not official. I leaned heavily on the excellent documentation on Pantheon (linked in various spots below). Written quickly, after the fact. Ping me if something doesn't go right, and always remember to backup your work :)

Pre-requisites:

  1. Have a Pantheon account/site
  2. Have a CircleCI account authorized to work with GitHub
  3. Have a GitHub account/repo

Notes

The premise of this is pretending you're making a brand new, squeakly clean, Build-Tools based Pantheon D8 site from scratch. Once it's setup, we start integrating/copying things to our existing D8 site/repo. So if you have an existing D8 site called "mysite," use "mysite2" for everything in the official directions.

I also needed to disable some of the tests since things like non-standard code formatting in custom modules would cause builds to fail, which would prevent multi-dev environments from updating and ultimately prevent deployment up to Pantheon's dev environment. You could just fix all your code, but depending on the project that may take a few days.

Steps

  1. Convert to composer: https://pantheon.io/docs/guides/composer-convert/, but note the line If you do plan on using a CI solution, refer to our Build Tools guide at this point. Do not finish - use the link in there. Make sure you keep/move all your custom modules, themes, and config to the new /web/ webroot directories.
  2. Commit the changes to your repo. You can safely remove all the files that are now managed by composer (core, vendor, etc).
  3. Follow all the steps from https://pantheon.io/docs/guides/build-tools/ (intro)
  4. Follow all the steps from https://pantheon.io/docs/guides/build-tools/create-project/ (setup)
  5. In CircleCI, you should now have this mysite2 setup and working. It should be building MultiDev sites in Pantheon, too.
  6. In CircleCI, follow your OLD (Existing) D8 site (make it so it's available to run jobs/integrate with GitHub). You can test it by pushing a test branch to your original site repo and seeing that branch show up in circle CI.
  7. In CircleCI, copy all the env vars from mysite2 to mysite (from the one generated by the steps above to the original repo you just added to CircleCI). Located in Workflow > reponame (gear icon) > Environment Variables. The key here is using terminus/pantheon values for your original site instead of the one generated above. You will likely have to generate some new tokens.
  8. I think I am forgetting something else I did here...
  9. Now when you commit and push another branch to the original repo, mysite/test-branch, you should see it start building in both CircleCI and you should get a new MultiDev in Pantheon on the original Pantheon site.
  10. When you merge the next branch to master (and it passes all tests), it should automatically merge it to your Pantheon's Dev environment, with the database that was always there (no need to migrate). Once that is done, you simply deploy up using the Pantheon Dashboard (or terminus) the way you're used to, up to Test and then to Live.

Questions/feedback

  • DM me on Pantheon's Slack community :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment