-
Notifications
You must be signed in to change notification settings - Fork 70
/
.gitlab-ci.yml
57 lines (53 loc) · 1.53 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
# define stages
stages:
- build
- upload
- deploy
# gitbook docker image for html & pdf
image: billryan/gitbook
pdf:
stage: build
tags:
- handbook-docker
script:
- gitbook install
- gitbook pdf . ./handbook.pdf
artifacts:
name:
handbook
paths:
- handbook.pdf
html:
stage: build
tags:
- handbook-docker
script:
- gitbook install
- gitbook build
artifacts:
name:
html
paths:
- _book
# create docker nginx image
upload-image:
stage: upload
image: docker:latest
tags:
- handbook-docker-priv
services:
- docker:dind
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN docker.ii.org.nz
- docker build -t docker.ii.org.nz/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_BUILD_REF_NAME .
- docker push docker.ii.org.nz/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_BUILD_REF_NAME
# run nginx container
publish-to-web:
stage: deploy
tags:
- handbook-shell
script:
- docker pull docker.ii.org.nz/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_BUILD_REF_NAME
- docker rm -f $CI_BUILD_REF_NAME.$CI_PROJECT_NAME.$CI_PROJECT_NAMESPACE || /bin/true
- docker run --name $CI_BUILD_REF_NAME.$CI_PROJECT_NAME.$CI_PROJECT_NAMESPACE --env "VIRTUAL_HOST=$CI_BUILD_REF_NAME.$CI_PROJECT_NAMESPACE.$CI_PROJECT_NAME.ii.org.nz" --network $DOCKER_PROJECT_NETWORK -d docker.ii.org.nz/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_BUILD_REF_NAME
- echo Website available at http\://$CI_BUILD_REF_NAME.$CI_PROJECT_NAMESPACE.$CI_PROJECT_NAME.ii.org.nz