Skip to content

Instantly share code, notes, and snippets.

@meherranjan meherranjan/post-receive forked from lemiorhan/post-receive
Last active Mar 16, 2018

Embed
What would you like to do?
Post-receive hook to deploy the code being pushed to production branch to a specific folder
#!/bin/bash
target_branch="gh-pages"
working_tree="/home/meherranjan/aerosailor.com"
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then
GIT_WORK_TREE=$working_tree git checkout $target_branch -f
NOW=$(date +"%Y%m%d-%H%M")
git tag release_$NOW $target_branch
echo " /==============================="
echo " | DEPLOYMENT COMPLETED"
echo " | Target Branch: $target_branch"
echo " | Target Folder: $working_tree"
echo " | Tag Name : release_$NOW"
echo " \=============================="
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.