Skip to content

Instantly share code, notes, and snippets.

@chadmayfield
Created June 2, 2019 21:19
Show Gist options
  • Save chadmayfield/a9dd44781eba1c0d89dcdfa1ac4f52a3 to your computer and use it in GitHub Desktop.
Save chadmayfield/a9dd44781eba1c0d89dcdfa1ac4f52a3 to your computer and use it in GitHub Desktop.
Check version of a Github project and email (using cron)
#!/bin/bash
# check_version.sh - check github project for latest release version from cron & email
url="https://github.com/USER/REPO/releases/latest"
txt="/tmp/release.txt"
prj="$(echo $url | awk -F "/" '{print $4 "/" $5}')"
cmd="$(curl -sL -o /dev/null -w "%{url_effective}" ${url} | awk -F "/" '{print $NF}')"
if [ ! -f "$txt" ]; then
echo -n "Latest release: "
echo "$cmd" | tee "$txt"
else
if ! [[ "$cmd" =~ $(cat $txt) ]]; then
# TODO: add send email command
echo -n "Different versions send email! Repo $prj new version: "
echo "$cmd" | tee "$txt"
fi
fi
#EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment