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