Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
R3
howto-cards
Commits
baccec14
Commit
baccec14
authored
Jul 24, 2020
by
Jacek Lebioda
Browse files
Merge branch 'remove-old-deployment' into 'develop'
Remove old deployment See merge request
!160
parents
3a5a7c1c
3b7f3a7d
Pipeline
#30278
passed with stages
in 2 minutes and 14 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.ci/build_indices.sh
View file @
baccec14
#!/bin/bash
DIRECTORY
=
build
# Install lunr to build the index
npm
install
lunr@
2.3.8
npm
install
lunr@
$LUNR_VERSION
# Go to the directory...
# Go to the directory
containing the built website
...
cd
$DIRECTORY
printf
"Found the following build targets inside:
\n
$(
ls
-d
*
/
)
\n\n
"
# ...and loop through all the build targets
for
branch
in
$(
ls
-d
*
/
)
;
do
echo
"Entering:
$branch
"
;
cd
"
$branch
"
;
echo
"Generating the index..."
cat
documents.js | node
$CI_PROJECT_DIR
/build_index.js
>
index.js
rm
documents.js build_index.js
echo
"Generating the index..."
echo
"...should be completed. First 50 characters of the index: "
cat
index.js |
head
-c50
echo
""
# Pipe documents.js file (which should be generated by Jekyll after building the website) through build script
cat
documents.js | node build_index.js
>
index.js
cd
..
done
# Show the results (should not be empty)
echo
"...should be completed. First 50 characters of the index: "
cat
index.js |
head
-c50
echo
""
rm
$CI_PROJECT_DIR
/
build_index.js
rm
documents.js
build_index.js
.ci/build_indices_new.sh
deleted
100644 → 0
View file @
3a5a7c1c
#!/bin/bash
# Install lunr to build the index
npm
install
lunr@
$LUNR_VERSION
# Go to the directory containing the built website...
cd
$DIRECTORY
echo
"Generating the index..."
# Pipe documents.js file (which should be generated by Jekyll after building the website) through build script
cat
documents.js | node build_index.js
>
index.js
# Show the results (should not be empty)
echo
"...should be completed. First 50 characters of the index: "
cat
index.js |
head
-c50
echo
""
rm
documents.js build_index.js
.ci/deploy.sh
deleted
100644 → 0
View file @
3a5a7c1c
mkdir
-p
build
artefact
=
"latest"
# loop through all the branches
for
branch
in
$(
git
for
-each-ref
--format
=
'%(refname:strip=3)'
refs/remotes
)
;
do
echo
$branch
;
if
[[
$branch
==
"master"
]]
;
then
artefact
=
"stable"
;
elif
[[
$branch
==
"develop"
]]
;
then
artefact
=
"latest"
;
else
artefact
=
"unstable"
;
fi
echo
$artefact
;
git checkout
-f
$branch
git reset
--hard
$branch
git pull
# Generate the config dynamically
echo
'url: "https://r3.pages.uni.lu"'
>
_config_url.yml
# build the website
bundle
install
bundle
exec
jekyll build
--config
"_config.yml,_config_url.yml"
--baseurl
=
"howto-cards/
$artefact
"
-d
"build/
$artefact
"
if
[[
$branch
==
"master"
]]
;
then
# set the 404
cp
howto-cards/
$artefact
/404.html build/404.html
fi
done
# checkout the current branch
echo
$CI_COMMIT_REF_NAME
git checkout
-f
$CI_COMMIT_REF_NAME
git reset
--hard
origin/
$CI_COMMIT_REF_NAME
# set the auto redirection
cp
.ci/.autoRedirect build/index.html
.gitlab-ci.yml
View file @
baccec14
...
...
@@ -3,66 +3,13 @@ image: git-r3lab.uni.lu:4567/r3/docker/jekyll-lcsb:1.6
stages
:
-
build
-
generate
_index
-
generate
-
deploy
# !!!!!!! README !!!!!
# We are in the transition period - and the website is deployed two times - to gitlab pages and to a separate VM
# In order to migrate to a new deployment:
# 1) remove "Old deployment" section - build_pages, generate the search index and pages tasks
# 2) rename "new pages" to "pages" in the new deployment section, and "new_public" to "public"; you might also rename directories (skip "new" part)
# 3) remove ".ci/deploy.sh", ".ci/build_indices.sh"
# build
# ------------------------------------------------------------------------------------
# Old deployment =================================================================
build_pages
:
stage
:
build
before_script
:
-
apt-get -qq update
-
apt-get install -y -qq git-lfs
-
gem install bundler:2.0.2 && bundle install
script
:
-
bash .ci/deploy.sh
variables
:
JEKYLL_ENV
:
production
artifacts
:
expire_in
:
1 day
paths
:
-
build
generate the search index
:
stage
:
generate_index
image
:
node:13.8.0-slim
rules
:
-
if
:
$CI_COMMIT_BRANCH == "master"
-
if
:
$CI_COMMIT_BRANCH == "develop"
script
:
-
bash .ci/build_indices.sh
-
mv build processed_build
artifacts
:
expire_in
:
1 day
paths
:
-
processed_build
pages
:
image
:
alpine:3.11.3
stage
:
deploy
rules
:
-
if
:
$CI_COMMIT_BRANCH == "master"
-
if
:
$CI_COMMIT_BRANCH == "develop"
script
:
-
mv processed_build public
artifacts
:
expire_in
:
1 week
paths
:
-
public
# New deployment ==================================================================
build pages for VM deployment
:
build:pages:
stage
:
build
variables
:
JEKYLL_ENV
:
production
...
...
@@ -70,7 +17,7 @@ build pages for VM deployment:
artifacts
:
expire_in
:
1 day
paths
:
-
new_
build
-
build
rules
:
-
if
:
$CI_COMMIT_BRANCH
-
if
:
$CI_MERGE_REQUEST_ID
...
...
@@ -90,42 +37,47 @@ build pages for VM deployment:
-
'
echo
"Configuration:
"
&&
cat
".ci/_config_$CI_COMMIT_REF_NAME.yml"'
# Run Jekyll with custom configuration
-
bundle exec jekyll build -d
new_
build --config "_config.yml,.ci/_config_$CI_COMMIT_REF_NAME.yml"
-
bundle exec jekyll build -d build --config "_config.yml,.ci/_config_$CI_COMMIT_REF_NAME.yml"
# generate
# ------------------------------------------------------------------------------------
generate
the
search
i
ndex
for VM deployment
:
stage
:
generate
_index
generate
:
search
I
ndex:
stage
:
generate
image
:
node:13.8.0-slim
variables
:
LUNR_VERSION
:
2.3.8
DIRECTORY
:
new_
build
DIRECTORY
:
build
script
:
-
bash .ci/build_indices
_new
.sh
-
mv
new_
build
new_
processed_build
-
bash .ci/build_indices.sh
-
mv build processed_build
rules
:
-
if
:
$CI_COMMIT_BRANCH
-
if
:
$CI_MERGE_REQUEST_ID
artifacts
:
expire_in
:
1 day
paths
:
-
new_processed_build
-
processed_build
# deploy
# ------------------------------------------------------------------------------------
# Deploy to Gitlab Pages - to be run only by forks
; change to pages once it's ready
new
pages
:
# Deploy to Gitlab Pages - to be run only by forks
pages
:
image
:
alpine:3.11.3
stage
:
deploy
rules
:
-
if
:
'
$CI_PROJECT_NAMESPACE
!=
"R3"
&&
$CI_PROJECT_NAMESPACE
!=
"R3-core"'
-
if
:
$CI_MERGE_REQUEST_ID
script
:
-
mv
new_
processed_build
new_
public
-
mv processed_build public
artifacts
:
expire_in
:
1 week
paths
:
-
new_
public
-
public
## Deploys the website to a separate VM
deploy
to production
:
deploy
:vm
:
stage
:
deploy
image
:
alpine:3.1
before_script
:
...
...
@@ -141,6 +93,6 @@ deploy to production:
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
&&
$CI_PROJECT_PATH
==
"R3/howto-cards"'
script
:
-
ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/$CI_COMMIT_BRANCH/sources/public/$CI_JOB_ID ~/$CI_COMMIT_BRANCH/public"
-
scp -P $SSHPORT -r
new_
processed_build/* $SSHCONNECT:~/$CI_COMMIT_BRANCH/sources/public/$CI_JOB_ID
-
scp -P $SSHPORT -r processed_build/* $SSHCONNECT:~/$CI_COMMIT_BRANCH/sources/public/$CI_JOB_ID
-
ssh -p $SSHPORT $SSHCONNECT "cd ~/$CI_COMMIT_BRANCH/public && ln -fs ../sources/public/$CI_JOB_ID/* . && cd ~/$CI_COMMIT_BRANCH/sources/public/ && find . -type d -not -newermt '-1 minutes' -exec rm -rf {} +;"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment