Created
May 26, 2019 15:59
-
-
Save jeremejazz/75fb11ab0c6c9cd5e3481a5c753b5eab to your computer and use it in GitHub Desktop.
Hugo Theme Update Script. Uses git subtree
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 | |
# This script will download the latest theme release from the Github repository. | |
# requires jq | |
REPO="" # github "user/repo" | |
GITHUB_USERNAME="" | |
metas=$(echo $REPO | tr "/" "\n") | |
THEME_NAME=$(echo $metas | awk '{print $2}') | |
LATEST=$(curl -u $GITHUB_USERNAME https://api.github.com/repos/$REPO/tags | jq -r ".[0].name") | |
CURRENT=$(cat THEME_VERSION) | |
if [ $LATEST = $CURRENT ]; then | |
echo "Theme is up to date" | |
exit | |
fi | |
echo -n "Current version: $CURRENT Download Latest ($LATEST)? (y/n): " | |
read answer | |
echo "" | |
if [ "$answer" != "${answer#[Yy]}" ] ;then | |
rm -rf themes/$THEME_NAME | |
git subtree add --prefix themes/$THEME_NAME --squash https://github.com/$REPO.git $LATEST | |
#save new version to file | |
echo $LATEST > THEME_VERSION | |
echo "Theme downloaded" | |
else | |
echo "Download aborted" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment