Skip to content

Commit

Permalink
Add publish script
Browse files Browse the repository at this point in the history
  • Loading branch information
smockle committed Nov 15, 2019
1 parent 4d514d0 commit a554d8d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions hazel/publish.sh
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

0 comments on commit a554d8d

Please sign in to comment.