Skip to content

Commit

Permalink
Initial Commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
szipfel committed Mar 14, 2022
0 parents commit 64c632e
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: php
dist: xenial

services:
- docker

php:
- 7.4

script:
- npm install backstopjs
- echo "skipping tests"

env:
global:
- XDEBUG_MODE=coverage

install:
# - composer --verbose install
- echo "StrictHostKeyChecking no" > ~/.ssh/config
- .travis/deploy.sh
8 changes: 8 additions & 0 deletions .travis/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Hosting provider
# Available:
# - pantheon
# - acquia
HOSTING=pantheon
# UUID - This is the UUID for the config so manually updted databases
# can be updated via Config import without errors
UUID=1232 # coming soon. -- Prefil after site setup / prepare for host command.
5 changes: 5 additions & 0 deletions .travis/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

path=$(dirname "$0")
source $path/.env
source $path/$HOSTING/deploy.sh
119 changes: 119 additions & 0 deletions .travis/pantheon/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/usr/bin/env bash

CURRENT_BRANCH=`git name-rev --name-only HEAD`
TERMINUS_BIN=scripts/bin/terminus

quiet_git() {
stdout=$(tempfile)
stderr=$(tempfile)

if ! git "$@" </dev/null >$stdout 2>$stderr; then
cat $stderr >&2
rm -f $stdout $stderr
exit 1
fi

rm -f $stdout $stderr
}

# Update the pantheon sites, updb, cim and clear the cache.
update_site() {
sleep 120
echo "========================================="
echo "...Clearing caches"
echo "========================================="
$TERMINUS_BIN env:clear-cache $PANTHEON_SITE_ID.$P_ENV
echo "========================================="
echo "...Importing config"
echo "========================================="
$TERMINUS_BIN drush -n $PANTHEON_SITE_ID.$P_ENV cim -y
echo "========================================="
echo "...Running update DB"
echo "========================================="
$TERMINUS_BIN drush -n $PANTHEON_SITE_ID.$P_ENV updb -y
}

# delete files we don't want on Pantheon and copy in some that we do.
clean_artifacts() {
echo "========================================="
echo "...Generating site artifacts"
echo "========================================="
cp hosting/pantheon/* .
rm -rf .docksal
rm -rf web/sites/default/files
rm -rf hosting
}


echo "Logging into Terminus"
$TERMINUS_BIN auth:login --machine-token=$SECRET_TERMINUS_TOKEN
$TERMINUS_BIN connection:set $PANTHEON_SITE_ID.$PANTHEON_ENV git -y

echo "Add pantheon repo"
git remote add pantheon $PANTHEON_REPO

echo "Waking Pantheon $PANTHEON_SITE_ID Dev environment."
$TERMINUS_BIN env:wake -n $PANTHEON_SITE_ID.$PANTHEON_ENV

echo "... Pulling git"
git pull

echo "...Run composer install"
composer install

echo "...remove nested .git dirs from web and vendor directories recursively"
find web/ | grep .git | xargs rm -rf
find vendor/ | grep .git | xargs rm -rf



if [ "$CURRENT_BRANCH" != "$PANTHEON_ENV" ]; then
echo "========================================="
echo "...Building Branch on new Multidev"
echo "========================================="
echo "...Delete MD if it already exists"
$TERMINUS_BIN multidev:delete $PANTHEON_SITE_ID.ci-$TRAVIS_BUILD_NUMBER --delete-branch --yes
echo "...Building Mutlidev ci-$TRAVIS_BUILD_NUMBER"
$TERMINUS_BIN multidev:create $PANTHEON_SITE_ID.$PANTHEON_ENV ci-$TRAVIS_BUILD_NUMBER --yes

# Clean up the codebase before sending
clean_artifacts

echo "...Switch to new ci-$TRAVIS_BUILD_NUMBER branch locally"
git checkout -b ci-$TRAVIS_BUILD_NUMBER
echo "...Add the new files"
quiet_git add -f vendor/* web/* pantheon* config/*
quiet_git commit -m "Artifacts for build ci-$TRAVIS_BUILD_NUMBER"
echo "...Push to pantheon"
git push pantheon ci-$TRAVIS_BUILD_NUMBER --force
P_ENV="ci-$TRAVIS_BUILD_NUMBER"
update_site "$P_ENV"

else

echo "========================================="
echo "...Updating Develop Branch"
echo "========================================="

git checkout -b ci-$TRAVIS_BUILD_NUMBER

# Clean up the codebase before sending
clean_artifacts

echo "...Add the new files"
quiet_git add -f vendor/* web/* pantheon* config/*
echo "...Committig and pushing to Pantheon"
quiet_git commit -m "TRAVIS JOB: $TRAVIS_JOB_ID - $TRAVIS_COMMIT_MESSAGE"
echo "...Push to pantheon"
git push pantheon ci-$TRAVIS_BUILD_NUMBER:$PANTHEON_ENV --force
# set this for doing things on Pantheon later.
P_ENV=$PANTHEON_ENV
# Run site updates.
update_site "$P_ENV"
fi

# if we're only testing delete the MD used for said tests.
if [ "$CURRENT_BRANCH" != "$PANTHEON_ENV" ]; then
$TERMINUS_BIN multidev:delete $PANTHEON_SITE_ID.ci-$TRAVIS_BUILD_NUMBER --delete-branch --yes
fi

Empty file added .travis/pantheon/test.sh
Empty file.

0 comments on commit 64c632e

Please sign in to comment.