forked from kaitai-io/kaitai_struct_doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish
executable file
·81 lines (66 loc) · 2.2 KB
/
publish
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
78
79
80
81
#!/bin/sh -ef
# publish: publishes build results to a certain repository hosted at
# GitHub pages.
#
# Copyright (C) 2016-2017 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/>.
GH_USER=kaitai-io
GH_REPO_NAME=doc-kaitai-io.github.io
export GIT_AUTHOR_NAME='Kaitai Bot'
export GIT_AUTHOR_EMAIL='[email protected]'
export GIT_COMMITTER_NAME='Kaitai Bot'
export GIT_COMMITTER_EMAIL='[email protected]'
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 [email protected]:"$GH_USER"/"$GH_REPO_NAME".git
echo 'Updating the files from out...'
rsync --delete-after --exclude=.git --exclude=CNAME -r -v out/ "$GH_REPO_NAME"
cd "$GH_REPO_NAME"
echo 'Adding and committing...'
git add .
git commit -m Regen
echo 'Pushing...'
git push
echo -n 'Cleaning up the key and wrapper... '
rm "$HOME/bot_id" "$HOME/git-ssh"
echo OK