From 44da27fce1203d982eaf38217b2f0cdbdfcf2be8 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Tue, 13 Apr 2021 22:33:29 -0700 Subject: [PATCH] add cron_commits.sh --- cron_commits.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 cron_commits.sh diff --git a/cron_commits.sh b/cron_commits.sh new file mode 100755 index 0000000000000000000000000000000000000000..c32b6b57a1facd3b2aecf1ba0037661e6470e844 --- /dev/null +++ b/cron_commits.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -e + +most_recent='' + +while true +do + commits=$(curl -s https://api.github.com/repos/$1/commits) + sha=$(echo "$commits" | jq -r '.[0].sha') + + if [ -z "$most_recent" ] + then + most_recent="$sha" + echo "first run of loop, commit is $sha" + continue + fi + + if [ "$most_recent" == "$sha" ] + then + echo "most recent commit is the same, sleeping" + # sec - min - hr + sleep $((1 * 60 * 60 * $2)) + continue + fi + + echo "found new commit $sha" + ./generate.sh +done -- 2.54.0