Export config directly to Code Studio (GitLab)
- Last updated
- 1 minute read
Goal
Integrate Code Studio with your Drupal site so you can create a merge request with updated config with the click of a button.
Prerequisites
-
Acquia Code Studio or GitLab
-
Drupal 8/9/10
Overview
Sometimes, you gotta make config changes in production. Getting those changes back into code requires jumping through a few hoops. You'd typically need to copy the production database into a writable environment, export the configuration, commit it, and push it back upstream.
Not anymore. With Acquia Code Studio (powered by GitLab) and one handy contributed model, you can now revise that process to be a simple button click. Not database copying, local export, no local commit.
Here's how.
-
Install the config_patch_gitlab_api module.
composer require drupal/config_patch_gitlab_api
If you are using Acquia Search or Geocoder modules, then you may have a composer dependency issue. There is an issue open for that, and until that is closed, you may need to use the issue fork:
“drupal/config_patch_gitlab_api”: “dev-3259230-update-to-php-httpguzzle6-adapter”,
-
Enable the module
Use the UI to enable the module, or use Drush:
drush en config_patch_gitlab_api
-
Create a GitLab project access token
Log into Code Studio, and open the project you are connecting to.
In the Settings menu choose Access Tokens. Choose a name and optional expiry date for the token. Be sure to grant at least the
api
andwrite_repository
scopes. Then click the Create project access token button.Be sure to save the project access token somewhere safe. Once you leave or refresh
the page, you don't have access to it again. -
Set configuration values
Configure your site to connect to Code Studio on the following paths:
- Put in your token
/admin/config/config_patch_gitlab_api/credentials
- Choose the branch that you will create a MR for:
/admin/config/config_patch_gitlab_api/project_branch
- Adjust the other settings
/admin/config/development/config_patch
- Put in your token
-
Export your configuration to Code Studio
Once a configuration change has been made, you'll see a "Config changes" item in your toolbar with a number representing the number of config changes. Click on that item to visit the "Config patch" page.
Next, write the commit message for the Merge Request that will be created in Code Studio, select the config to export, and click "Create GitLab merge request."
That's it! You now have an open merge request that introduces the config changes that are present on your live Drupal site.
Acquia Code Studio's AutoDevOps will test your changes and even deploy them to a Continuous Delivery Environment where you can review and validate.