1 #!/bin/bash 2 3 set -ex 4 5 REPO="git (at] github.com:square/okhttp.git" 6 DIR=temp-clone 7 8 # Delete any existing temporary website clone 9 rm -rf $DIR 10 11 # Clone the current repo into temp folder 12 git clone $REPO $DIR 13 14 # Move working directory into temp folder 15 cd $DIR 16 17 # Checkout and track the gh-pages branch 18 git checkout -t origin/gh-pages 19 20 # Delete everything that isn't versioned (1.x, 2.x) 21 ls | grep -E -v '^\d+\.x$' | xargs rm -rf 22 23 # Copy website files from real repo 24 cp -R ../website/* . 25 26 # Stage all files in git and create a commit 27 git add . 28 git add -u 29 git commit -m "Website at $(date)" 30 31 # Push the new files up to GitHub 32 git push origin gh-pages 33 34 # Delete our temp folder 35 cd .. 36 rm -rf $DIR 37