Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microsites #181

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions db_import_new_site/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Database sanitization of user emails and passwords. #

This example will show you how you can automatically import a database when creating a new site from the UI.

The use case is multiple, but imagine for example building a microsite distribution, where

Use cases:

- Automation of microsites
- Automation of branding sites
- Automation of regional sites
- Others?

## Instructions ##

Setting up this example is easy:

1. Add either the db_import_new_site to the `private` directory of your code repository.
2. Add a Quicksilver operation to your `pantheon.yml` to fire the script spining up a new site.
3. Commit and push changes to your repository
4. Test creating a new site out of the current upstream codebase!

Optionally, you may want to use the `terminus workflow:watch yoursitename` command to get immediate debugging feedback.

### Example `pantheon.yml` ###

Here's an example of what your `pantheon.yml` would look like if this were the only Quicksilver operation you wanted to use:

```yaml

api_version: 1
workflows:
deploy_product:
after:
- type: webphp
description: Run drush deploy new site creation in dev
script: private/scripts/new_site.php
```

### TODO ###

Use a similar example executing config import/export for an approach following best practices
21 changes: 21 additions & 0 deletions db_import_new_site/db_import_new_site.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

echo ("\n==== Drupal Environment importing database ====\n");
// Get paths for imports
$path = $_SERVER['DOCUMENT_ROOT'] . '/private/data';

// Import database
echo ('Importing Database from ...');

// Please don't store your database in the repository. This is just for demo purposes.
echo "${path}/microsite-database.sql && drush cr";
$cmd = "drush sql:cli < ${path}/microsite-database.sql && drush cr";
passthru($cmd);

// Import media and files
echo ('Unzipping image files...');
$files = $_SERVER['HOME'] . '/files';
$cmd = "unzip ${path}/files.zip -d ${files}";
passthru($cmd);

echo ("\n==== Drupal Environment Initialization Complete ====\n");