forked from gpii-ops/gpii-version-updater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-version-wrapper
executable file
·41 lines (35 loc) · 1.26 KB
/
update-version-wrapper
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
#!/bin/sh
# This initial setup is essential, so abort if anything fails.
set -e
orig_dir="$(pwd)"
export GIT_SSH_COMMAND='ssh -i ~/.ssh/id_rsa.gpii-ci'
git config --global user.email "[email protected]"
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
# 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 --depth 10 [email protected]:gpii-ops/gpii-infra
cd gpii-infra/modules/deploy
git remote add gitlab [email protected]:gpii-ops/gpii-infra
# Failures in the main loop are ok, so continue if anything fails and try again
# on the next go around.
set +e
while true ; do
echo "Starting version check at $(date)"
git fetch --all --tags -p
git reset --hard origin/master
"$orig_dir/update-version"
if [ -n "$(git status --porcelain -- version.yml)" ]; then
git add version.yml
git commit -m"[auto] Update version.yml"
git push origin HEAD
git push gitlab HEAD
fi
sleep_secs=300
echo "Finished version check at $(date)"
echo "Sleeping $sleep_secs..."
sleep $sleep_secs
done