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
fc9c830a
Commit
fc9c830a
authored
Mar 25, 2020
by
Jacek Lebioda
Browse files
feat: some progress on new CI/CD pipeline
parent
d6b68bc0
Pipeline
#23319
failed with stages
in 21 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.ci/build_indices.sh
View file @
fc9c830a
#!/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/deploy.sh
deleted
100644 → 0
View file @
d6b68bc0
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
# build the website
bundle
install
bundle
exec
jekyll build
--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 @
fc9c830a
...
...
@@ -8,27 +8,35 @@ stages:
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
BUNDLER_VERSION
:
2.0.2
artifacts
:
expire_in
:
1 day
paths
:
-
build
before_script
:
-
gem install bundler:$BUNDLER_VERSION && bundle install
script
:
# Generate the configuration for forks (will use Gitlab Pages on personal namespaces)
-
'
echo
"url:
https://$CI_PROJECT_NAMESPACE.$CI_PAGES_DOMAIN\nbaseurl:
/$CI_PROJECT_NAME"
>>
_config_gitlab_pages.yml'
# If there is no config for the current branch, use the one for Gitlab Pages
-
'
if
[
!
-f
"_config_$CI_COMMIT_REF_NAME.yml"
];
then
mv
_config_gitlab_pages.yml
_config_$CI_COMMIT_REF_NAME.yml;
fi'
# Display, which configuration is used
-
'
echo
"Configuration:
"
&&
cat
"_config_$CI_COMMIT_REF_NAME.yml"'
# Run Jekyll with custom configuration
-
bundle exec jekyll build -d build --config "_config.yml,_config_$CI_COMMIT_REF_NAME.yml"
generate the search index
:
stage
:
generate_index
image
:
node:13.8.0-slim
rules
:
-
if
:
$CI_COMMIT_BRANCH == "master"
-
if
:
$CI_COMMIT_BRANCH == "develop"
-
if
:
$CI_COMMIT_BRANCH == "16-deploy-to-staticpages-vm"
variables
:
LUNR_VERSION
:
2.3.8
DIRECTORY
:
build
script
:
-
bash .ci/build_indices.sh
-
mv build processed_build
...
...
@@ -37,14 +45,16 @@ generate the search index:
paths
:
-
processed_build
# Deploy to Gitlab Pages - to be run only by forks
pages
:
image
:
alpine:3.11.3
stage
:
deploy
rules
:
-
if
:
$CI_COMMIT_BRANCH == "master"
-
if
:
$CI_COMMIT_BRANCH == "develop"
-
if
:
'
$CI_PROJECT_NAMESPACE
!=
"R3"
&&
$CI_PROJECT_NAMESPACE
!=
"R3-core"'
script
:
-
mv processed_build public
# For safety reasons:
-
sleep 3600 && exit -1
-
mv processed_buildXXXXX publicXXXX
artifacts
:
expire_in
:
1 week
paths
:
...
...
@@ -67,7 +77,9 @@ Deploy to production:
-
if
:
'
$CI_COMMIT_BRANCH
==
"master"
&&
$CI_PROJECT_PATH
==
"R3/howto-cards"'
-
if
:
'
$CI_COMMIT_BRANCH
==
"16-deploy-to-staticpages-vm"'
script
:
-
ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/sources/public/web_$CI_JOB_ID ~/master"
# Disable that for now
-
sleep 3600 && exit -1
-
ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/sources/$CI_COMMIT_BRANCH/$CI_JOB_ID ~/master ~/develop"
-
scp -P $SSHPORT -r processed_build/* $SSHCONNECT:~/sources/public/web_$CI_JOB_ID
-
ssh -p $SSHPORT $SSHCONNECT "cd ~/master && ln -fs ~/sources/public/web_$CI_JOB_ID/* . && cd ~/sources/public/ && find . -type d -not -newermt '-1 minutes' -exec rm -rf {} +;"
_config.yml
View file @
fc9c830a
...
...
@@ -19,8 +19,8 @@ description: >- # this means to ignore newlines until "baseurl:"
This page is an index for lab cards that are intended to provide practical guidance in implementing Data Management, Data Protection and IT setup.
# URL settings (the most difficult part, please refer to the guide)
baseurl
:
"
/
howto-cards
"
# the subpath of your site, e.g. /gitlab-repository-name
url
:
"
https://
r3.pages.uni.lu
"
# the base hostname & protocol for your site, e.g. http://gitlab-namespace-name.pages.uni.lu/
baseurl
:
"
/"
# the subpath of your site, e.g. /gitlab-repository-name
url
:
"
https://
localhost
"
# the base hostname & protocol for your site, e.g. http://gitlab-namespace-name.pages.uni.lu/
# Banner settings
banner
:
howto-card
# When you have custom images, change this setting's value to the name of the folder containing them
...
...
@@ -62,6 +62,8 @@ plugins:
# The display logic itself is in the template
share_url
:
https://howto.lcsb.uni.lu/?
include_link_index
:
4
# These values are injected into cards
defaults
:
-
scope
:
...
...
_config_devel.yml
0 → 100644
View file @
fc9c830a
url
:
"
https://howto-latest.lcsb.uni.lu"
baseurl
:
"
/"
_config_master.yml
0 → 100644
View file @
fc9c830a
url
:
"
https://howto.lcsb.uni.lu"
baseurl
:
"
/"
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