-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsync_images_wrapper
More file actions
executable file
·51 lines (41 loc) · 1.58 KB
/
sync_images_wrapper
File metadata and controls
executable file
·51 lines (41 loc) · 1.58 KB
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
48
49
50
51
#!/bin/sh
# Abort if anything fails.
set -e
orig_dir="$(pwd)"
versions_file='shared/versions.yml'
export GIT_SSH_COMMAND='ssh -i ~/.ssh/id_rsa.gpii-ci'
git config --global user.email "gpii-bot@gpii.net"
git config --global user.name "GPII Bot"
# When an existing container is restarted, the sandbox is left behind. Clear it
# out and start over.
rm -rf gpii-infra
# When the container restarts, dockerd dies and can orphan some runtime state
# files (pid file, sockets). This prevents dockerd from starting in the
# restarted container, so we clean it up.
rm -rf /var/run/docker.pid /var/run/docker
# Start dockerd in the background and give it a few seconds to start up before
# potentially trying to use it.
dockerd &
sleep 5
# We don't need the full history, but we want a few previous revisions in case
# we need those revisions to push to a remote (e.g. gitlab) that hasn't been
# updated in a bit.
git clone --no-tags --depth 10 git@github.com:gpii-ops/gpii-infra
cd gpii-infra
gpii_infra_dir="$(pwd)"
while true ; do
echo "Starting version check at $(date)"
git fetch --all --depth=10 -p
git reset --hard origin/master
(cd "${orig_dir}" && rake sync"[${gpii_infra_dir}/${versions_file}, ALL, true, gcr.io/gpii-common-prd]")
if [ -n "$(git status --porcelain -- ${versions_file})" ]; then
git add "${versions_file}"
git --no-pager diff --cached
git commit -m"[auto] Update ${versions_file}"
git push origin HEAD
fi
sleep_secs=300
echo "Finished version check at $(date)"
echo "Sleeping $sleep_secs..."
sleep $sleep_secs
done