-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathbot.sh
47 lines (40 loc) · 995 Bytes
/
bot.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
#
# Commit Bot by Steven Kneiser
#
# > https://github.com/theshteves/commit-bot
#
# Deploy locally by adding the following line to your crontab:
# 0 22 * * * /bin/bash /<full-path-to-your-folder>/code/commit-bot/bot.sh
#
# Edit your crontab in vim w/ the simple command:
# crontab -e
#
# Deploying just on your computer is better than a server if you want
# your commits to more realistically mirror your computer usage.
#
# ...c'mon, nobody commits EVERY day ;)
#
info="Commit: $(date)"
echo "OS detected: $OSTYPE"
case "$OSTYPE" in
darwin*)
cd "`dirname $0`" || exit 1
;;
linux*)
cd "$(dirname "$(readlink -f "$0")")" || exit 1
;;
*)
echo "OS unsupported (submit an issue on GitHub!)"
;;
esac
echo "$info" >> output.txt
echo "$info"
echo
# Detect current branch (main, master, etc)
branch=$(git rev-parse --abbrev-ref HEAD)
# Ship it
git add output.txt
git commit -m "$info"
git push origin "$branch"
cd -