Created
February 4, 2018 00:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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