Skip to content

Instantly share code, notes, and snippets.

@doidor
Created October 16, 2015 09:02
Show Gist options
  • Save doidor/aa95bf419b047d5b1da1 to your computer and use it in GitHub Desktop.
Save doidor/aa95bf419b047d5b1da1 to your computer and use it in GitHub Desktop.
Simple shell script for bundling a repo using git archive.
#!/bin/bash
GIT_BRANCH='<the_branch>'
SERVER_IP='<remote_server_ip>'
SERVER_USER='<remote_user>'
DEFAULT_COPY_PATH='<remote_path_where_to_copy_the_bundle>'
INSTALL_SCRIPT="install.sh"
# you can specify a custom git branch if you want
if [ $# -gt 0 ]; then
GIT_BRANCH=$1
fi
CURRENT_TS=$(date +"%Y-%m-%d_%H-%M-%S")
RELEASE_NAME=$GIT_BRANCH"_"$CURRENT_TS
BUNDLE_NAME=$RELEASE_NAME.tar.gz
git archive --format=tar $GIT_BRANCH | gzip > $BUNDLE_NAME
if [ ! -f $BUNDLE_NAME ]; then
echo "Failed to create bundle"
exit 1
fi
scp $INSTALL_SCRIPT $BUNDLE_NAME $SERVER_USER@$SERVER_IP:$DEFAULT_COPY_PATH
echo "Done. Cleaning up..."
rm -rf $BUNDLE_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment