Last active
December 16, 2015 10:40
-
-
Save mike-boddin/e323916cd34c280a54b2 to your computer and use it in GitHub Desktop.
Revisions
-
mike-boddin revised this gist
Dec 16, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/bin/bash # post-receive ### STEP 1: Load some convenient functions #################################### # import base_functions # it provides: log, print_baseline, quit -
mike-boddin created this gist
Dec 16, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ #!/bin/bash # base_functions function print_baseline { echo "#" echo "########################################################################" echo "#" } function log { echo "# $@" } function quit { print_baseline exit 0 } print_baseline This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ #!/bin/bash # post-receive ### STEP 1: Load some convinient functions #################################### # import base_functions # it provides: log, print_baseline, quit source `pwd`/${0%/*}/base_functions ### STEP 2: Set params ######################################################## # production-path to copy content to PRODUCTION_PATH=~/html # read stdin into an arry, split by whitespace IFS=' ' read -a INPUT #previous commit id ID_BEFORE=${INPUT[0]} # new commit id ID_AFTER=${INPUT[1]} # branch BRANCH=${INPUT[2]} # the version we want to print to the version-file VERSION=${ID_AFTER:0:7} # the version-file VERSION_FILE=version.txt ### STEP 3: check the branch (we only want to process the master-branch) ###### # if not the master-branch was pushed --> exit if ! [[ $BRANCH == *master ]] ; then log this is the ${BRANCH##*/}-branch, no additional action log if you want to deploy to production, please push to the master-branch quit else log push to master, the content will be deployed to production fi ### STEP 4: copy over the content ############################################# # copy over content to production export GIT_WORK_TREE=$PRODUCTION_PATH git checkout -f # add version information echo $VERSION > $PRODUCTION_PATH/$VERSION_FILE log production updated to version $VERSION quit