-
Notifications
You must be signed in to change notification settings - Fork 75
/
.gitlab-ci.yml
109 lines (93 loc) · 3.09 KB
/
.gitlab-ci.yml
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
image: ruby:2.5
variables:
LC_ALL: "C.UTF-8"
LANG: "en_US.UTF-8"
LANGUAGE: "en_US.UTF-8"
stages:
- build
- deploy
build:
tags:
- docs
stage: build
artifacts:
paths:
- _site/
script:
- |
cat /etc/debian_version || true
uname -a
echo "Merge marker sanity check"
(grep -ri "<<<<<<" * || grep -ri ">>>>>>" *) && (echo "found some merge conflicts, will abort"; exit -1)
echo "## removing old _site directory"
rm -rf ./_site
echo "## building docs"
bundle install
bundle exec jekyll build --config _config.yml,_versions.yml
deploy:
tags:
- docs
stage: deploy
dependencies:
- build
only:
- release
before_script:
- apt-get update -yqq
- apt-get install -yqq ncftp wget
- bundle install
script:
- |
site_dir=$(grep "baseurl:" ./_versions.yml | awk '{print $2}')
sftp_directory=$(sed 's/^\///' <<< $site_dir )
sftp_root_directory='html'
#set default SFTP server
if [ ! ${sftp_server+x} ]; then
sftp_server=185.233.188.50
fi
#set default cloudflare zoneid
if [ ! ${SG_CLOUDFLARE_ZONEID+x} ]; then
SG_CLOUDFLARE_ZONEID=21f0b97bf3df0f55bba6ca46b746da1f
fi
if [ ! ${REMOVE_CLOUDFLARE_CACHE+x} ]; then
REMOVE_CLOUDFLARE_CACHE=true
fi
echo "Building branch $git_branch"
if [ "$ftp_file_upload" = true ] ; then
echo "## Uploading to FTP directory: $site_dir"
ncftpput -R -v -u $ftp_username -p $ftp_password 35.214.156.137 "$site_dir" ./_site/*
export GIT_COMMIT_DESC=$(git log --format=oneline -n 1 $CIRCLE_SHA1)
echo "Last commit message: $GIT_COMMIT_DESC"
else
echo "FTP upload is disabled"
fi
if [ "$sftp_file_upload" = true ] ; then
echo "## Uploading to SFTP Server $sftp_server directory: $ftp_dir"
echo "Set ssh configuration for SFTP"
which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )
eval $(ssh-agent -s)
echo "$sftp_user_private_key_base64" | base64 -d | tr -d '\r' | ssh-add -
mkdir -p ~/.ssh
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
echo "Uploading fles to SFTP server"
sftp -b - $sftp_user_name@$sftp_server <<EOF
-mkdir $sftp_root_directory/$sftp_directory
put -r /builds/search-guard/search-guard-docs/_site/* $sftp_root_directory/$sftp_directory
EOF
else
echo "SFTP upload is disabled"
fi
if $REMOVE_CLOUDFLARE_CACHE ; then
echo "Deleting Cloudflare Cache"
curl \
-X POST "https://api.cloudflare.com/client/v4/zones/$SG_CLOUDFLARE_ZONEID/purge_cache" \
-H "Authorization: Bearer $SG_CLOUDFLARE_DECACHE_TOKEN" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'
fi
if [[ $GIT_COMMIT_DESC == *"noindex"* ]]; then
echo "## Skipping Search Index"
else
echo "## Rebuilding Search Index"
bundle exec jekyll algolia push --config _config.yml,_versions.yml
fi