Skip to content

Instantly share code, notes, and snippets.

@chrisroane
Created November 22, 2017 22:10
Show Gist options
  • Save chrisroane/3acf0e16203a7206f08d00090e9a5e26 to your computer and use it in GitHub Desktop.
Save chrisroane/3acf0e16203a7206f08d00090e9a5e26 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Start mysql and create database.
sudo service mysql start
mysql -uroot -e "CREATE DATABASE circle_test"
set -ex
# Install the required node modules.
npm install
npm rebuild node-sass
# Install composer dependencies.
composer install --no-ansi --no-interaction --optimize-autoloader --no-progress
#=====================================================================================================================
# Start EXPORTing needed environment variables
# Circle CI 2.0 does not yet expand environment variables so they have to be manually EXPORTed
# Once environment variables can be expanded this section can be removed
# See: https://discuss.circleci.com/t/unclear-how-to-work-with-user-variables-circleci-provided-env-variables/12810/11
# See: https://discuss.circleci.com/t/environment-variable-expansion-in-working-directory/11322
# See: https://discuss.circleci.com/t/circle-2-0-global-environment-variables/8681
#=====================================================================================================================
echo 'export PATH=$PATH:$HOME/bin' >> $BASH_ENV
echo 'export BRANCH=$(echo $CIRCLE_BRANCH | grep -v '"'"'^\(master\|[0-9]\+.x\)$'"'"')' >> $BASH_ENV
echo 'export PR_ENV=${BRANCH:+pr-$BRANCH}' >> $BASH_ENV
echo 'export CIRCLE_ENV=ci-$CIRCLE_BUILD_NUM' >> $BASH_ENV
echo 'export TERMINUS_ENV=${TERMINUS_ENV:-$DEFAULT_ENV}' >> $BASH_ENV
# Set up global commands.
sudo ln -s ~/medstat/vendor/bin/terminus /usr/bin/terminus
sudo ln -s ~/medstat/vendor/bin/behat /usr/bin/behat
sudo ln -s ~/medstat/node_modules/.bin/aquifer /usr/bin/aquifer
# Refresh the bash.
source $BASH_ENV
#===========================================
# End EXPORTing needed environment variables
#===========================================
# Bail on errors
set +ex
# Setup Terminus and get aliases.
/usr/bin/env COMPOSER_BIN_DIR=$HOME/bin composer --working-dir=$HOME require pantheon-systems/terminus "^1"
terminus auth:login -n --machine-token="$PTOKEN" --email="$PEMAIL"
terminus aliases
# Configure drush.
sudo mkdir -p ~/.drush
cp ~/medstat/.circleci/settings/medstat.aliases.drushrc.php ~/.drush
drush cc drush
# Copy config files.
cp ~/medstat/.circleci/settings/behat.circle.yml ~/medstat/behat.local.yml
cp ~/medstat/.circleci/settings/secret.settings.php ~/medstat/settings
echo $'Host *\nLogLevel quiet' >> ~/.ssh/config
# Load aquifer extensions.
test -d .aquifer || aquifer extensions-load
# Create directory for temporary + private files.
sudo mkdir ~/medstat/tmp
sudo mkdir ~/medstat/private
sudo chown -R www-data:www-data ~/medstat/tmp
sudo chown -R www-data:www-data ~/medstat/private
sudo chmod -R 777 ~/medstat/tmp
sudo chmod -R 777 ~/medstat/private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment