forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload_docs.sh
executable file
·63 lines (50 loc) · 1.37 KB
/
upload_docs.sh
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
#!/usr/bin/env bash
set -e
set -x
if [[ $CI_COMMIT_REF_NAME != "master" ]]; then
# Development version
dest_branch=${CI_COMMIT_REF_NAME}
deploy_repo="[email protected]:lfortran/web/docs.lfortran.org-testing.git"
else
# Release version
dest_branch="master"
deploy_repo="[email protected]:lfortran/docs.lfortran.org.git"
fi
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
ssh-keyscan github.com >> ~/.ssh/known_hosts
eval "$(ssh-agent -s)"
set +x
if [[ "${SSH_PRIVATE_KEY_DOCS}" == "" ]]; then
echo "Note: SSH_PRIVATE_KEY_DOCS is empty, skipping..."
exit 0
fi
# Generate the private/public key pair using:
#
# ssh-keygen -f deploy_key -N ""
#
# then set the $SSH_PRIVATE_KEY_DOCS environment variable in the GitLab-CI to
# the base64 encoded private key:
#
# cat deploy_key | base64 -w0
#
# and add the public key `deploy_key.pub` into the target git repository (with
# write permissions).
ssh-add <(echo "$SSH_PRIVATE_KEY_DOCS" | base64 -d)
set -x
D=`pwd`
mkdir $HOME/repos
cd $HOME/repos
git clone ${deploy_repo} docs-deploy
cd docs-deploy
rm -rf docs
mkdir docs
echo "docs.lfortran.org" > docs/CNAME
cp -r $D/site/* docs/
git config user.name "Deploy"
git config user.email "noreply@deploy"
COMMIT_MESSAGE="Deploying on $(date "+%Y-%m-%d %H:%M:%S")"
git add .
git commit -m "${COMMIT_MESSAGE}"
git push origin +master:$dest_branch