-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve build/deploy scripts/instructions (#113)
* make bin/build more robust * make bin/deploy more robust * exclude Makefile from build/deploy * consolidate build/deploy/etc instructions into README * update exclude config to remove old files
- Loading branch information
1 parent
b0ad9f1
commit e0ebd22
Showing
6 changed files
with
149 additions
and
62 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,63 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env zsh | ||
|
||
set -e | ||
|
||
# Variables | ||
SITE_DIR="_site" | ||
REPO_URL="https://github.com/0xdevalias/devalias.net" | ||
BRANCH="gh-pages" | ||
|
||
# Function to prompt the user for yes/no input with a default response | ||
prompt_yes_no() { | ||
local prompt=$1 | ||
local default=${2:-Y} | ||
|
||
local yn | ||
while true; do | ||
if [[ $default == [Yy]* ]]; then | ||
echo -n "$prompt [Y/n]: " | ||
read yn | ||
yn=${yn:-Y} | ||
else | ||
echo -n "$prompt [y/N]: " | ||
read yn | ||
yn=${yn:-N} | ||
fi | ||
|
||
case $yn in | ||
[Yy]* ) return 0;; | ||
[Nn]* ) return 1;; | ||
* ) echo "Please answer yes or no.";; | ||
esac | ||
done | ||
} | ||
|
||
# Function to check if the site directory is a valid git repository with the correct branch | ||
check_site_setup() { | ||
if [ -d "$SITE_DIR" ] && [ -d "$SITE_DIR/.git" ]; then | ||
if (cd "$SITE_DIR" && git rev-parse --verify "$BRANCH" > /dev/null 2>&1); then | ||
return 0 | ||
fi | ||
fi | ||
return 1 | ||
} | ||
|
||
# Function to clone the branch into the site directory | ||
setup_site_clone() { | ||
rm -rf "$SITE_DIR" | ||
git clone -b "$BRANCH" "$REPO_URL" "$SITE_DIR" | ||
} | ||
|
||
# Main script logic | ||
if ! check_site_setup; then | ||
echo "WARNING: $SITE_DIR directory does not exist or is not a proper git repository." | ||
if prompt_yes_no "Would you like to set up the $SITE_DIR directory as a clone of the $BRANCH branch?" Y; then | ||
setup_site_clone | ||
else | ||
echo "Error: $SITE_DIR directory is not set up. Aborting build." | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Build the Jekyll site | ||
JEKYLL_ENV=production bundle exec jekyll build --lsi --profile $@ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,50 @@ | ||
#!/bin/sh | ||
#!/usr/bin/env zsh | ||
|
||
set -e | ||
|
||
# Variables | ||
SITE_DIR="_site" | ||
REPO_URL="https://github.com/0xdevalias/devalias.net" | ||
BRANCH="gh-pages" | ||
|
||
# Function to check if the site directory is a valid git repository with the correct branch | ||
check_site_setup() { | ||
if [ -d "$SITE_DIR" ] && [ -d "$SITE_DIR/.git" ]; then | ||
if git -C "$SITE_DIR" rev-parse --verify "$BRANCH" > /dev/null 2>&1; then | ||
return 0 | ||
fi | ||
fi | ||
return 1 | ||
} | ||
|
||
# Function to check for changes in the site directory | ||
check_for_changes() { | ||
if git -C "$SITE_DIR" diff --quiet && git -C "$SITE_DIR" diff --cached --quiet; then | ||
return 1 | ||
fi | ||
return 0 | ||
} | ||
|
||
# Main script logic | ||
if ! check_site_setup; then | ||
echo "ERROR: $SITE_DIR directory does not exist or is not a proper git repository." | ||
echo | ||
echo "Please set up the $SITE_DIR directory as a clone of the $BRANCH branch." | ||
echo | ||
echo "You can do this automatically by running:" | ||
echo " bin/build" | ||
echo | ||
echo "Or manually with the following commands:" | ||
echo " rm -rf $SITE_DIR" | ||
echo " git clone -b $BRANCH $REPO_URL $SITE_DIR" | ||
exit 1 | ||
fi | ||
|
||
# Check for changes before deployment | ||
if ! check_for_changes; then | ||
echo "No changes to deploy." | ||
exit 0 | ||
fi | ||
|
||
# Deploy the Jekyll site | ||
bundle exec jekyll deploy $@ |