Skip to content

Instantly share code, notes, and snippets.

@jnaskali
Last active May 5, 2018 08:49
Show Gist options
  • Save jnaskali/429a3491b493e2c7f09a487b91876d67 to your computer and use it in GitHub Desktop.
Save jnaskali/429a3491b493e2c7f09a487b91876d67 to your computer and use it in GitHub Desktop.
Bash script to check for new GitHub releases
#!/bin/bash
#
# Check if GitHub repos have new releases, compare to last run and notify through AutoRemote, if change
#
# Requires xidel from http://www.videlibri.de/xidel.html#downloads
# Saves last run to /tmp/latest_reponame.txt files
# Array of tracked GitHub repos
githubrepos=('mholt/caddy')
authkey="NOTMYREALKEY"
updates=""
for i in ${githubrepos[@]}; do
name=$(echo "${i}" | tr -cd '[a-z]')
current=$([ -f /tmp/latest_${name}.txt ] && cat /tmp/latest_${name}.txt)
githublatest=$(xidel https://github.com/${i}/releases.atom -se //entry[1]/title)
if [[ "$current" != "$githublatest" ]];
then
echo "$githublatest" > /tmp/latest_${name}.txt
updates="${updates}${i} ${githublatest}\n"
fi
done
# Send notification, if updates found (var not empty)
if [[ -n "$updates" ]];
then
curl -s "https://autoremotejoaomgcd.appspot.com/sendnotification?key=${authkey}&title=Updates%20available&statusbaricon=action_about_dark" --data-urlencode "text=${updates}" > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment