Hi again! If you haven’t read the first part of this article, then you might want to give a look at Continuous Deployment for Drupal 7 (part 1) before moving onto this one.
If you already read it, then great! Let’s continue then.
At this point you know that to implement your continuous deployment workflow for your Drupal project you have to:
- Do everything in code (the most you have in code, the less you’ll have to do manually using the Drupal admin interface).
- Use the hook_update_N for Drupal (and create a custom module for it, you’ll keep your things more organized).
- Install and use Drush, so you can use the Shell (console, terminal, you name it according to your OS) to run commands.
Now, we have everything in place, we just have to create a pipeline (or workflow, use the name that best fits for you) to complete the process.
- Add your changes to the code.
- Push to the develop branch (as an example, you can set a pipeline for every branch you need).
- Automatically send the changes to the development environment.
- Pull the changes
- Create a database backup
- Run the pending database updates (yes, your code inside the hook_update_N will be executed at this point)
- Clear the cache
At inQbation we use DeployBot for some Drupal projects, you just have to connect it to your repository, configure the access to the server and (literally) copy/paste the shell instructions, so they run every time your branch is updated.
Bonus: You can add some integrations to get notified about every deploy process. You can set an automated email to be sent, or a message via Slack (our choice). This is very helpful to have quick access to the output of the Continuous Deployment process.