Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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