-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebuild-docker
executable file
·44 lines (35 loc) · 1.25 KB
/
rebuild-docker
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
#!/bin/bash
if ! git rev-parse --verify -q origin/master >/dev/null; then
git remote set-branches origin --add master
fi
if ! git rev-parse --verify -q origin/linux-docker >/dev/null; then
git remote set-branches origin --add linux-docker
fi
git fetch origin
master_rev=$(git rev-parse origin/master)
docker_parent=$(git log -1 --format='%P' origin/linux-docker)
[ "$master_rev" == "$docker_parent" ] && exit 0
echo "Triggering rebuild of docker branch..."
rebuild_dir="$(mktemp -d machineinfo-XXXXX)"
git branch -D linux-docker-rebuild 2>/dev/null
git branch linux-docker-rebuild origin/master
git clone --branch linux-docker-rebuild ./ "$rebuild_dir"
(
cd "$rebuild_dir"
perl -i -e'while(<>){ if (/^branches:/) { while(<>) { last if /^\S/ } } print unless /^sudo:/ }' .travis.yml
echo "
sudo: false
branches:
include:
- linux-docker
" >> .travis.yml
git add .travis.yml
export GIT_AUTHOR_NAME="$(git log -n 1 --format='%an')"
export GIT_AUTHOR_EMAIL="$(git log -n 1 --format='%ae')"
export GIT_COMMITTER_NAME="Travis CI"
export GIT_COMMITTER_EMAIL="travis-ci@$(hostname -f)"
git commit -m"Build for linux-docker"
git push -f origin linux-docker-rebuild
)
rm -rf "$rebuild_dir"
git push -f origin linux-docker-rebuild:linux-docker