Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
howto-cards
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marie Fossepre
howto-cards
Commits
62c2ae21
Commit
62c2ae21
authored
4 years ago
by
Jacek Lebioda
Browse files
Options
Downloads
Patches
Plain Diff
feat: double deployment
parent
0207c873
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.ci/build_indices.sh
+22
-10
22 additions, 10 deletions
.ci/build_indices.sh
.ci/build_indices_new.sh
+19
-0
19 additions, 0 deletions
.ci/build_indices_new.sh
.ci/deploy.sh
+35
-0
35 additions, 0 deletions
.ci/deploy.sh
.gitlab-ci.yml
+69
-15
69 additions, 15 deletions
.gitlab-ci.yml
with
145 additions
and
25 deletions
.ci/build_indices.sh
+
22
−
10
View file @
62c2ae21
#!/bin/bash
#!/bin/bash
DIRECTORY
=
build
# Install lunr to build the index
# Install lunr to build the index
npm
install
lunr@
$LUNR_VERSION
npm
install
lunr@
2.3.8
# Go to the directory
containing the built website
...
# Go to the directory...
cd
$DIRECTORY
cd
$DIRECTORY
echo
"Generating the index..."
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
# Pipe documents.js file (which should be generated by Jekyll after building the website) through build script
echo
"...should be completed. First 50 characters of the index: "
cat
documents.js | node build_index.js
>
index.js
cat
index.js |
head
-c50
echo
""
# Show the results (should not be empty)
cd
..
echo
"...should be completed. First 50 characters of the index: "
cat
index.js |
head
-c50
done
echo
""
rm
documents.js
build_index.js
rm
$CI_PROJECT_DIR
/
build_index.js
This diff is collapsed.
Click to expand it.
.ci/build_indices_new.sh
0 → 100644
+
19
−
0
View file @
62c2ae21
#!/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
This diff is collapsed.
Click to expand it.
.ci/deploy.sh
0 → 100644
+
35
−
0
View file @
62c2ae21
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
--url
=
"https://r3.pages.uni.lu"
--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
This diff is collapsed.
Click to expand it.
.gitlab-ci.yml
+
69
−
15
View file @
62c2ae21
...
@@ -6,15 +6,71 @@ stages:
...
@@ -6,15 +6,71 @@ stages:
-
generate_index
-
generate_index
-
deploy
-
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"
# 3) remove ".ci/deploy.sh", ".ci/build_indices.sh"
# Old deployment =================================================================
build_pages
:
build_pages
:
stage
:
build
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
:
variables
:
JEKYLL_ENV
:
production
JEKYLL_ENV
:
production
BUNDLER_VERSION
:
2.0.2
artifacts
:
artifacts
:
expire_in
:
1 day
expire_in
:
1 day
paths
:
paths
:
-
build
-
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
:
stage
:
build
variables
:
JEKYLL_ENV
:
production
BUNDLER_VERSION
:
2.0.2
artifacts
:
expire_in
:
1 day
paths
:
-
new_build
before_script
:
before_script
:
-
gem install bundler:$BUNDLER_VERSION && bundle install
-
gem install bundler:$BUNDLER_VERSION && bundle install
script
:
script
:
...
@@ -29,40 +85,38 @@ build_pages:
...
@@ -29,40 +85,38 @@ build_pages:
-
'
echo
"Configuration:
"
&&
cat
".ci/_config_$CI_COMMIT_REF_NAME.yml"'
-
'
echo
"Configuration:
"
&&
cat
".ci/_config_$CI_COMMIT_REF_NAME.yml"'
# Run Jekyll with custom configuration
# Run Jekyll with custom configuration
-
bundle exec jekyll build -d build --config "_config.yml,.ci/_config_$CI_COMMIT_REF_NAME.yml"
-
bundle exec jekyll build -d
new_
build --config "_config.yml,.ci/_config_$CI_COMMIT_REF_NAME.yml"
generate the search index
:
generate the search index
for VM deployment
:
stage
:
generate_index
stage
:
generate_index
image
:
node:13.8.0-slim
image
:
node:13.8.0-slim
variables
:
variables
:
LUNR_VERSION
:
2.3.8
LUNR_VERSION
:
2.3.8
DIRECTORY
:
build
DIRECTORY
:
new_
build
script
:
script
:
-
bash .ci/build_indices.sh
-
bash .ci/build_indices
_new
.sh
-
mv build processed_build
-
mv build
new_
processed_build
artifacts
:
artifacts
:
expire_in
:
1 day
expire_in
:
1 day
paths
:
paths
:
-
processed_build
-
new_
processed_build
# Deploy to Gitlab Pages - to be run only by forks
# Deploy to Gitlab Pages - to be run only by forks
; change to pages once it's ready
pages
:
new
pages
:
image
:
alpine:3.11.3
image
:
alpine:3.11.3
stage
:
deploy
stage
:
deploy
rules
:
rules
:
-
if
:
'
$CI_PROJECT_NAMESPACE
!=
"R3"
&&
$CI_PROJECT_NAMESPACE
!=
"R3-core"'
-
if
:
'
$CI_PROJECT_NAMESPACE
!=
"R3"
&&
$CI_PROJECT_NAMESPACE
!=
"R3-core"'
script
:
script
:
# For safety reasons:
-
mv new_processed_build new_public
-
sleep 3600 && exit -1
-
mv processed_buildXXXXX publicXXXX
artifacts
:
artifacts
:
expire_in
:
1 week
expire_in
:
1 week
paths
:
paths
:
-
public
-
new_
public
## Deploys the website to a separate VM
## Deploys the website to a separate VM
D
eploy to production
:
d
eploy to production
:
stage
:
deploy
stage
:
deploy
image
:
alpine:3.1
image
:
alpine:3.1
before_script
:
before_script
:
...
@@ -79,6 +133,6 @@ Deploy to production:
...
@@ -79,6 +133,6 @@ Deploy to production:
-
if
:
'
$CI_COMMIT_BRANCH
==
"16-deploy-to-staticpages-vm"'
-
if
:
'
$CI_COMMIT_BRANCH
==
"16-deploy-to-staticpages-vm"'
script
:
script
:
-
ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/sources/public/$CI_COMMIT_BRANCH/$CI_JOB_ID ~/master/public ~/develop/public ~/$CI_COMMIT_BRANCH/public"
-
ssh -p $SSHPORT $SSHCONNECT "mkdir -p ~/sources/public/$CI_COMMIT_BRANCH/$CI_JOB_ID ~/master/public ~/develop/public ~/$CI_COMMIT_BRANCH/public"
-
scp -P $SSHPORT -r processed_build/* $SSHCONNECT:~/sources/public/$CI_COMMIT_BRANCH/$CI_JOB_ID
-
scp -P $SSHPORT -r
new_
processed_build/* $SSHCONNECT:~/sources/public/$CI_COMMIT_BRANCH/$CI_JOB_ID
-
ssh -p $SSHPORT $SSHCONNECT "cd ~/$CI_COMMIT_BRANCH/public && ln -fs ~/sources/public/$CI_COMMIT_BRANCH/$CI_JOB_ID/* . && cd ~/sources/public/$CI_COMMIT_BRANCH && find . -type d -not -newermt '-1 minutes' -exec rm -rf {} +;"
-
ssh -p $SSHPORT $SSHCONNECT "cd ~/$CI_COMMIT_BRANCH/public && ln -fs ~/sources/public/$CI_COMMIT_BRANCH/$CI_JOB_ID/* . && cd ~/sources/public/$CI_COMMIT_BRANCH && find . -type d -not -newermt '-1 minutes' -exec rm -rf {} +;"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment