Skip to content

Instantly share code, notes, and snippets.

@erickzanardo
Created January 11, 2016 16:05
Show Gist options
  • Save erickzanardo/02d39aef78999ed5cc0c to your computer and use it in GitHub Desktop.
Save erickzanardo/02d39aef78999ed5cc0c to your computer and use it in GitHub Desktop.
Simple bash script to "deploy" some static project to github pages
#!/bin/bash
FOLDER=$1
REMOTE=$2
if [ "$2" = "" ]
then
REMOTE="origin"
fi
REMOTEURL="remote.$REMOTE.url"
REMOTEURL=`git config --get $REMOTEURL`
mkdir /tmp/ghpp
echo "#######################"
echo "# Clonning repository #"
echo "#######################"
echo ""
git clone -b gh-pages --single-branch $REMOTEURL /tmp/ghpp
echo "######################"
echo "# Cleaning old files #"
echo "######################"
echo ""
rm -rf /tmp/ghpp/*
echo "#####################"
echo "# Copying new files #"
echo "#####################"
echo ""
cp -r $FOLDER/* /tmp/ghpp/
cd /tmp/ghpp
git add . -A
git commit -am"Updating static files"
git push $REMOTE gh-pages
rm -rf /tmp/ghpp
echo "########"
echo "# DONE #"
echo "########"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment