Skip to content

Instantly share code, notes, and snippets.

@ModulesUnraveled
Last active May 14, 2017 23:34
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ModulesUnraveled/661fe8ff04144230a90adf23d857315c to your computer and use it in GitHub Desktop.
Save ModulesUnraveled/661fe8ff04144230a90adf23d857315c to your computer and use it in GitHub Desktop.
Useful Drush shell-aliases for Drupal 8 development.
<?php
/**
* These aliases (while working) are NO LONGER MAINTAINED.
*
* Development has moved to a full github repo here:
* https://github.com/ModulesUnraveled/Drush-Shell-Aliases
*
* I'm doing this to make it more easy to include them in your Drupal 8 projects.
* All future development will happen there.
*
* Thank you!
* - Brian
*
* P.S. If you have questions about how to use these, send me a message on Twitter @ModsUnraveled
*/
// The first example "statusss" is just a simple test
// to make sure your environment is reading this file
// To test, run `drush @yoursite.instance statusss`
$options['shell-aliases'] = array(
'statusss' =>
'!echo "\nChecking the status of {{@target}}"
drush {{@target}} status
echo "\nChecking the status of {{@target}} again"
drush {{@target}} status
echo "Finished checking the status of {{@target}} twice"',
'data-stage' =>
'!echo "\nReplacing the {{@target}} database with the one from {{#stage}}"
drush sql-sync -y {{#stage}} {{@target}} --create-db --sanitize',
'data-live' =>
'!echo "\nReplacing the {{@target}} database with the one from {{#live}}"
drush sql-sync -y {{#live}} {{@target}} --create-db --sanitize',
'files-stage' =>
'!echo "\nSyncing files from {{#Stage}} to {{@target}}"
drush rsync -y {{#Stage}}:%files {{@target}}:%files',
'files-stage' =>
'!echo "\nSyncing files from {{#Stage}} to {{@target}}"
drush rsync -y {{#Stage}}:%files {{@target}}:%files',
'files-live' =>
'!echo "\nSyncing files from {{#live}} to {{@target}}"
drush rsync -y {{#live}}:%files {{@target}}:%files',
'confex' =>
"!echo '\nDisabling development modules'
drush {{@target}} pmu -y $(cat ../mods_enabled.local | tr '\n' ' ')
echo '\nExporting configuration'
drush {{@target}} cex -y
echo '\nRe-enabling development modules'
drush {{@target}} en -y $(cat ../mods_enabled.local | tr '\n' ' ')",
'confim' =>
"!echo '\nImporting configuration'
drush {{@target}} cim -y
echo '\nEnabling development modules'
drush {{@target}} en -y $(cat ../mods_enabled.local | tr '\n' ' ')
echo '\nUpdating database'
drush {{@target}} updb -y
echo '\nClearing caches'
drush {{@target}} cr",
'rebuild' =>
"!echo '\nRunning composer install from the project root'
cd ..
composer install
drush {{@target}} data-live
drush {{@target}} confim
echo '\nLogging into {{@target}} as uid1'
drush {{@target}} uli uid=1",
'confim-no-dev' =>
'!echo "\nImporting configuration"
drush {{@target}} cim -y
echo "\nUpdating database"
drush {{@target}} updb -y
echo "\nClearing caches"
drush {{@target}} cr',
'stage-rebuild' =>
"!echo '\Pulling latest staging branch'
git checkout staging
git pull
echo '\nRunning composer install from the project root'
cd ..
composer install --no-dev
drush {{@target}} confim-no-dev
echo '\nUse the following link to log into {{@target}} as uid1'
drush {{@target}} uli uid=1 --no-browser",
'live-rebuild' =>
"!echo '\Pulling latest master branch'
git checkout master
git pull
echo '\nRunning composer install from the project root'
cd ..
composer install --no-dev
drush {{@target}} confim-no-dev
echo '\nUse the following link to log into {{@target}} as uid1'
drush {{@target}} uli uid=1 --no-browser",
'deploy-stage' =>
"!echo '\nDeploying the latest state of the develop branch to staging'
echo 'Pulling the latest develop branch'
git checkout develop
git pull
echo '\nMerging develop into staging'
git checkout staging
git merge develop
echo '\nCreating a release tag with the current date and time'
echo 'Then pushing everything (including tags) to master'
git tag REL-STAGING-$(date +'%Y%m%d-%H%M%S')
git push --tags
git push origin staging
echo '\nChecking out the develop branch'
git checkout develop",
'deploy-live' =>
"!echo '\nDeploying the latest state of the staging branch to master'
echo 'Pulling the latest staging branch'
git checkout staging
git pull
echo '\nMerging staging into master'
git checkout master
git merge staging
echo '\nCreating a release tag with the current date and time'
echo 'Then pushing everything (including tags) to master'
git tag REL-LIVE-$(date +'%Y%m%d-%H%M%S')
git push --tags
git push origin master
echo '\nChecking out the develop branch'
git checkout develop",
);
<?php
/**
* This file should be placed on the live server at:
* ~/.drush/mysite.aliases.drushrc.php
*/
// Live site
$aliases["live"] = array (
'root' => '/path/to/drupal/root',
'uri' => 'live.mysite.com',
);
<?php
/**
* This file should be placed on the local machine at:
* ~/.drush/mysite.aliases.drushrc.php
*/
// local site
$aliases["loc"] = array (
'uri' => 'loc.mysite.com',
'root' => '/path/to/drupal/root',
'#loc' => '@mysite.loc',
'#stage' => '@mysite.stage',
'#live' => '@mysite.live',
);
// Staging site
$aliases["stage"] = array (
'uri' => 'stage.mysite.com',
'root' => '/path/to/drupal/root',
'remote-host' => 'stage.server.com',
'remote-user' => 'username',
);
// Live site
$aliases["live"] = array (
'uri' => 'live.mysite.com',
'root' => '/path/to/drupal/root',
'remote-host' => 'live.server.com',
'remote-user' => 'username',
);
<?php
/**
* This file should be placed on the staging server at:
* ~/.drush/mysite.aliases.drushrc.php
*
* Remember to add the staging site's ssh key to
* the live server in order to use the live alias
*/
// Staging site
$aliases["staging"] = array (
'root' => '/path/to/drupal/root',
'uri' => 'stage.mysite.com',
'#live' => '@mysite.live',
);
// Live site
$aliases["live"] = array (
'uri' => 'live.mysite.com',
'root' => '/path/to/drupal/root',
'remote-host' => 'live.server.com',
'remote-user' => 'username',
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment