forked from kaitai-io/kaitai_struct
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-ci-status
executable file
·77 lines (64 loc) · 2.13 KB
/
update-ci-status
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/sh -ef
# update-ci-status: updates CI status on protected site hosted at GitHub
# pages.
#
# Copyright (C) 2016 Kaitai Project
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if [ -z "$BOT_SSH_KEY" ]; then
echo "BOT_SSH_KEY is not set!"
exit 1
fi
unset SSH_AGENT_PID SSH_AUTH_SOCK
echo -n 'Setting up bot key... '
echo "$BOT_SSH_KEY" | base64 -d >$HOME/bot_id
chmod 600 $HOME/bot_id
echo OK
echo -n 'Checking if key looks valid... '
key_head=$(head -n1 $HOME/bot_id)
if [ "$key_head" != '-----BEGIN RSA PRIVATE KEY-----' ]; then
echo 'Nope, key seems to be invalid'
exit 1
fi
echo -n 'OK, '
sha1sum $HOME/bot_id
# Alas, it seems that Travis CI uses ancient git that doesn't support this
#export GIT_SSH_COMMAND="ssh -i $HOME/bot_id"
# Squelch long git push strategy explanations
git config --global push.default simple
echo -n 'Setting up ssh wrapper... '
cat >$HOME/git-ssh <<__EOF__
#!/bin/sh -ef
ssh -i "$HOME/bot_id" "\$@"
__EOF__
chmod a+x $HOME/git-ssh
export GIT_SSH="$HOME/git-ssh"
echo 'OK'
echo 'Cloning website repo...'
git clone git@github.com:kaitai-io/kaitai-io.github.io.git
echo 'Updating the report...'
cd kaitai-io.github.io
cp ../test_out/full.html ci/index.html
echo 'Committing...'
GIT_AUTHOR_NAME='Kaitai Bot' \
GIT_AUTHOR_EMAIL='kaitai-bot@kaitai.io' \
GIT_COMMITTER_NAME='Kaitai Bot' \
GIT_COMMITTER_EMAIL='kaitai-bot@kaitai.io' \
git commit -m "Updated with build results on $(date -Iseconds --utc)" \
ci/index.html
echo 'Pushing...'
git push
echo -n 'Cleaning up the key and wrapper... '
rm "$HOME/bot_id" "$HOME/git-ssh"
echo OK