-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env zsh | ||
|
||
publish_blog() { | ||
if [ ! -d "${HOME}/.hazel/smockle.com" ]; then | ||
osascript -e 'display notification "Missing git repository, checked '~/.hazel/smockle.com'." with title "Publish Blog"' | ||
exit 1 | ||
fi | ||
cd "${HOME}/.hazel/smockle.com" | ||
git add . && \ | ||
git stash; \ | ||
git switch master; \ | ||
git pull; \ | ||
$(git stash pop || exit 0) | ||
if [ -z "$(git status --porcelain)" ]; then | ||
osascript -e 'display notification "Skipped publish. smockle.com/blog is already up-to-date." with title "Publish Blog"' | ||
exit 0 | ||
fi | ||
git commit -am "Update posts" | ||
local PUBLISH_BLOG_STATUS=$? | ||
if [ ! $PUBLISH_BLOG_STATUS -eq 0 ]; then | ||
osascript -e 'display notification "Failed to publish to smockle.com/blog." with title "Publish Blog"' | ||
exit 1 | ||
fi | ||
git push \ | ||
&& osascript -e 'display notification "Successfully published to smockle.com/blog." with title "Publish Blog"' \ | ||
|| osascript -e 'display notification "Failed to publish to smockle.com/blog." with title "Publish Blog"' | ||
} | ||
publish_blog | ||
unset publish_blog |