Created
June 12, 2024 15:21
-
-
Save wcaleb/67d7554ce2be625a090f8a72a6cd92d6 to your computer and use it in GitHub Desktop.
Script for publishing updates to my Gitit wiki to Micro.blog via curl
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
#!/bin/bash | |
# change to directory that holds my Gitit wiki | |
cd /path/to/dir/with/git/repo | |
if git log -1 --pretty=%s | grep -iq tweak; then | |
exit 0 | |
else | |
MESSAGE="Updated some notes in my open research notebook:" | |
SHA=`git rev-parse HEAD` | |
while read -r page | |
do | |
PAGE=${page%%.page} | |
PAGEURL=`echo "$PAGE" | sed 's/ /%20/g'` | |
export MESSAGE+=" [$PAGE](http://wiki.wcaleb.rice.edu/_diff/$PAGEURL?to=$SHA)," | |
done <<< "`git diff-tree --no-commit-id HEAD --name-only -r | grep -v @`" | |
MESSAGE=`echo "$MESSAGE" | rev | sed -e 's/,/./' | rev` | |
curl --silent \ | |
--data "h=entry" \ | |
--data-urlencode "content=${MESSAGE}" \ | |
--header "Authorization: Bearer XXXXXXXXXXXXX" \ | |
"https://micro.blog/micropub" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment