Skip to content

Instantly share code, notes, and snippets.

@heinrichreimer
Created February 4, 2018 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heinrichreimer/0bee5be4af58d316e5fda61b82fd3d29 to your computer and use it in GitHub Desktop.
Save heinrichreimer/0bee5be4af58d316e5fda61b82fd3d29 to your computer and use it in GitHub Desktop.
Script that runs on my web server and fetches, builds and deploys my personal portfolio. Portfolio sources can be found here: https://github.com/heinrichreimer/heinrichreimer.github.io
#!/usr/bin/env bash
set -e # Halt script on error.
# GitHub repo to fetch the portfolio from.
PORTFOLIO_REPO_USERNAME=heinrichreimer
PORTFOLIO_REPO_NAME=heinrichreimer.github.io
# Path to deploy the portfolio to.
PORTFOLIO_DEPLOY_PATH=~/www/heinrichreimer.com
echo -e "This script will generate a static portfolio based on the \"$PORTFOLIO_REPO_USERNAME/$PORTFOLIO_REPO_NAME\" GitHub repository.\n"
if [ ! -d "$PORTFOLIO_REPO_NAME/.git" ]; then
echo "Cloning the portfolio repo from GitHub..."
git clone https://github.com/$PORTFOLIO_REPO_USERNAME/$PORTFOLIO_REPO_NAME.git
echo -e "\e[32mSuccessfully cloned the repo. \e[0m"
echo -e "\n"
# Navigate to the cloned folder
cd $PORTFOLIO_REPO_NAME
else
# Navigate to the cloned folder
cd $PORTFOLIO_REPO_NAME
echo "Updating the portfolio repo..."
git fetch --all
git reset --hard origin/master
echo -e "\e[32mSuccessfully fetched the last repo version. \e[0m"
echo -e "\n"
fi
# Build the static pages.
chmod +x ./build.sh
./build.sh
echo "Copying the portfolio to the public website..."
cp -r ./_site/* $PORTFOLIO_DEPLOY_PATH
echo "Cleaning up temporary files..."
rm -rf ./_site
echo -e "\e[32mDone! The new website is now live. \e[0m"
echo -e "\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment