Last active
December 13, 2015 17:19
-
-
Save jeffreyroberts/4947370 to your computer and use it in GitHub Desktop.
Magento Deployment Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -f /tmp/git-pull.pid ] | |
then | |
exit 0 | |
fi | |
cd /v2a/sites/mage/mage.base | |
GIT_OUTPUT=`git pull` | |
if [ "$GIT_OUTPUT" -eq "Already up-to-date." ] | |
then | |
# Nothing to do, Exit | |
exit | |
fi | |
# Create Folder For New Deployment | |
/bin/mkdir -p /v2a/sites/mage/deployed.{1..4} | |
# Remove Oldest Deployment | |
rm -rf /v2a/sites/mage/deployed.4 | |
# Shift Existing Deployments | |
for i in {4..2} | |
do | |
/bin/mv /v2a/sites/mage/deployed.$[${i}-1] /v2a/sites/mage/deployed.${i} | |
done | |
# Copy Updated Mage Repo to Temp Deployment | |
cp -R /v2a/sites/mage/mage.base /v2a/sites/mage/temp.deployment | |
cd /v2a/sites/mage/temp.deployment | |
ln -s /v2a/sites/cdn-origin/public/media/ /v2a/sites/mage/temp.deployment/media | |
# Shift Current Production To Most Recent | |
mv /v2a/sites/mage/deployed /v2a/sites/mage/deployed.1 | |
# Shift New Deployment To Production | |
mv /v2a/sites/mage/temp.deployment /v2a/sites/mage/deployed | |
# Get Hostname, If WebHead-02 (Admin), Then Clear Cache | |
current_host=`hostname | awk -F. '{print $1}'` | |
if [ "$current_host" != "webhead-02" ] | |
then | |
# Nothing to do, Exit | |
exit 0 | |
fi | |
# Clear Cache | |
zf clear mage-core-cache tags=CONFIG | |
zf clear mage-core-cache tags=LAYOUT_GENERAL_CACHE_TAG | |
zf clear mage-core-cache tags=BLOCK_HTML | |
zf clear mage-core-cache tags=TRANSLATE | |
zf clear mage-core-cache tags=CONFIG_API | |
zf clear mage-core-cache tags=CONFIG_API2 | |
zf clear mage-core-cache tags=FPC | |
zf flush mage-core-cache | |
# Update Campfire | |
v2 sushi "Successfully Deployed Latest Magento Commit To Master." | |
# Trigger Cache Warming | |
# Not Implemented Yet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment