Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # The "post-receive" script is run after receive-pack has accepted a pack
- # and the repository has been updated. It is passed arguments in through
- # stdin in the form
- # <oldrev> <newrev> <refname>
- # arguments
- read oldrev newrev refname
- # dirs
- LIBS_DIR="/var/www/libs";
- SOURCE_DIR="$GL_REPO_BASE_ABS/$GL_REPO.git"
- TARGET_DIR="$LIBS_DIR/$GL_REPO"
- # cleanup the environment
- unset GIT_DIR
- # processes
- fix_permissions () {
- find $1 -type d -exec chmod 755 {} \;
- find $1 -type f -exec chmod 644 {} \;
- }
- # export_ref [ref] [directory]
- export_ref () {
- git archive $1 | (cd $2 && tar xf -)
- }
- # decide whether to deploy
- case $refname in
- refs/heads/* )
- BRANCH="${refname:11}"
- TARGET="$TARGET_DIR/$BRANCH/"
- echo "Executing deploy of library $GL_REPO, brach $BRANCH"
- cd $SOURCE_DIR && export_ref $BRANCH $TARGET
- fix_permissions $TARGET
- ;;
- refs/tags/* )
- TAG="${refname:10}"
- TARGET="$TARGET_DIR/$TAG/"
- echo "Executing deploy of library $GL_REPO, tag $BRANCH"
- cd $SOURCE_DIR && export_ref $TAG $TARGET
- fix_permissions $TARGET
- ;;
- * )
- ;;
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment