generalize the git gh-pages build step

Now it works with staging or production and is more flexible
remove old dead code