Post-Deployment Automation

Applies to: FlexLab

Overview

Automation runs short scripts on FlexSite *after* GitLab finishes deploying your code. Typical jobs: import Drupal configuration, rebuild caches, or reindex search — tasks that must happen on the live server, not in GitLab’s build container.

Key concepts

  • Post-deploy — the moment the new code is live but Drupal may still need housekeeping commands.
  • Drush — Drupal shell tool; common commands include drush cr (cache rebuild) and drush cim -y (import config).
  • Order matters — automation steps run top to bottom; import config before cache rebuild, for example.

Steps

  1. Open Environments, select an environment, then Automation.
  2. Click Add script (or similar) for each step.
  3. Choose type Drush, WP-CLI, or Shell as appropriate for Drupal projects use Drush.
  4. Enter commands such as drush updatedb -y, drush cim -y, drush cr.
  5. Drag steps to reorder, then Save.
  6. Push a commit to trigger the pipeline; open deployment logs to confirm automation succeeded.

GitLab CI vs FlexSite Automation

| Where | Best for |

|-------|----------|

| GitLab CI (.gitlab-ci.yml) | Running tests, compiling assets, building artifacts |

| FlexSite Automation | Commands that must run against the live Drupal database on FlexSite |

Store API keys referenced in shell scripts as Environment Variables on the same Automation page.