forked from dalibo/workshops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
101 lines (87 loc) · 2.54 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
## PRO TIP : Test your changes locally with :
## gitlab-ci-multi-runner exec docker {name_of_the_job}
##
## I N C L U D E S
##
# How To Export artefacts to the private environment
include:
- project: 'dalibo/gitlab-templates'
file: 'artifacts_private_env.yml'
##
## V A R I A B L E S
##
variables:
BRANCH_TARGET: ws14
MASTER_TARGET: all
# $ARTIFACTS is required by artefacts_private_env.yml
ARTIFACTS: '_build/*'
#
THEMES_BRANCH: stable # usually 'stable' or 'master'
## Limitation des pull docker
## https://gitlab.dalibo.info/formation/manuels/-/issues/482
## Pointer temporairement vers un registre cache externe chez Gitlab (https://gitlab.com/dalibo/pandocker/container_registry/1505688)
CI_REGISTRY: registry.gitlab.com
before_script:
# Prepare for Deploy Keys
# see https://docs.gitlab.com/ee/ci/ssh_keys/README.html#ssh-keys-when-using-the-docker-executor
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
#
# We use the same image for all jobs
#
image:
name: dalibo/pandocker:20.02 # usually 'stable' or 'latest' (=master)
entrypoint: [""] # we need to override the image entrypoint
##
## B U I L D
##
pandoc:
stage: build
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
TARGET: $MASTER_TARGET
ACTION: archives
MESSAGE: "All archived and active workshops will be published."
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
variables:
TARGET: $BRANCH_TARGET
ACTION: deploy
MESSAGE: "Only $BRANCH_TARGET will be published."
script:
#
# The dalibo themes are not mandatory
# CI should be able to run without it
#
- >
if [[ $GITLAB_DEPLOY_PRIVATE_KEY ]] ; then
ssh-add <(echo "$GITLAB_DEPLOY_PRIVATE_KEY")
git clone -b $THEMES_BRANCH git@gitlab.dalibo.info:marketing/themes.git
make --directory=themes install
fi
# pandoc
- echo $MESSAGE
- make $TARGET
- echo "Move html and pdf files to root directories"
- make $ACTION
artifacts:
paths:
- _build/fr/
- _build/en/
expire_in: 1 day
##
## D E P L O Y
##
## Export the master branch in a public location
public:
stage: deploy
script:
## Install Deploy Key
- ssh-add <(echo "$CLOUD_DEPLOY_PRIVATE_KEY")
## Push
- rsync -avp fr $CLOUD_DEPLOY_DEST
- rsync -avp en $CLOUD_DEPLOY_DEST
only:
- master@formation/workshops