summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/github-hosts-sync/src/hosts-sync
blob: d2017ef635f838acf5319f5d62633d177a110201 (plain)
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
#! /bin/sh
set -efu
exec >&2

hosts_srcdir=$GITHUB_HOST_SYNC_SRCDIR
hosts_worktree=${GITHUB_HOST_SYNC_WORKTREE-/tmp/hosts}
hosts_url=${GITHUB_HOST_SYNC_URL-git@github.com:krebs/hosts.git}

test -d "$hosts_worktree" || git clone "$hosts_url" "$hosts_worktree"

cd "$hosts_worktree"

git pull

rsync \
    --chmod D755,F644 \
    --delete-excluded \
    --filter 'protect .git' \
    --recursive \
    --verbose \
    "$hosts_srcdir/" \
    .

git add .

if test -n "$(git status --porcelain)"; then
  git config user.email "$LOGNAME@$(hostname)"
  git config user.name "$LOGNAME"
  git commit -m bump
  git push
fi