.gitlab-ci.yml 2.38 KB
Newer Older
David Hrbáč's avatar
David Hrbáč committed
1
2
3
4
5
6
stages:
  - test
  - build
  - deploy
  - production

Lukáš Krupčík's avatar
Lukáš Krupčík committed
7
8
9
10
11
docs:
  stage: test
  image: davidhrbac/docker-mdcheck:latest
  allow_failure: true
  script:
David Hrbáč's avatar
David Hrbáč committed
12
  - mdl -r ~MD013 *.md docs.it4i/
Lukáš Krupčík's avatar
Lukáš Krupčík committed
13

David Hrbáč's avatar
David Hrbáč committed
14
mkdocs:
David Hrbáč's avatar
David Hrbáč committed
15
  stage: build
David Hrbáč's avatar
David Hrbáč committed
16
17
  image: davidhrbac/docker-mkdocscheck:latest
  script:
David Hrbáč's avatar
David Hrbáč committed
18
19
  #- apt-get update
  #- apt-get -y install git
20
  - bash add_version.sh
David Hrbáč's avatar
David Hrbáč committed
21
  - bash get_modules.sh
David Hrbáč's avatar
David Hrbáč committed
22
  - mkdocs build
David Hrbáč's avatar
David Hrbáč committed
23
24
25
26
  artifacts:
    paths:
    - site
    expire_in: 1 week
David Hrbáč's avatar
David Hrbáč committed
27

Lukáš Krupčík's avatar
Lukáš Krupčík committed
28
29
30
shellcheck:
  stage: test
  image: davidhrbac/docker-shellcheck:latest
David Hrbáč's avatar
David Hrbáč committed
31
  allow_failure: true
Lukáš Krupčík's avatar
Lukáš Krupčík committed
32
33
34
  script:
  - which shellcheck || apt-get update && apt-get install -y shellcheck
  - shellcheck *.sh
David Hrbáč's avatar
David Hrbáč committed
35

David Hrbáč's avatar
David Hrbáč committed
36
37
38
deploy to stage:
  environment: stage 
  stage: deploy
David Hrbáč's avatar
David Hrbáč committed
39
  image: davidhrbac/docker-mkdocscheck:latest
David Hrbáč's avatar
David Hrbáč committed
40
41
42
  before_script:
  # install ssh-agent 
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
David Hrbáč's avatar
David Hrbáč committed
43
  - 'which rsync || ( apt-get update -y && apt-get install rsync -y )'
David Hrbáč's avatar
David Hrbáč committed
44
45
46
47
48
49
  # run ssh-agent
  - eval $(ssh-agent -s)
  # add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
  - ssh-add <(echo "$SSH_PRIVATE_KEY")
  # disable host key checking (NOTE: makes you susceptible to man-in-the-middle attacks)
  # WARNING: use only in docker container, if you use it with shell you will overwrite your user's ssh config
David Hrbáč's avatar
David Hrbáč committed
50
  - mkdir -p ~/.ssh
David Hrbáč's avatar
David Hrbáč committed
51
  - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
David Hrbáč's avatar
useradd    
David Hrbáč committed
52
  - useradd -lM nginx
David Hrbáč's avatar
David Hrbáč committed
53
  script:
David Hrbáč's avatar
David Hrbáč committed
54
  - chown nginx:nginx site -R
David Hrbáč's avatar
David Hrbáč committed
55
  - rsync -a --delete site/ root@"$SSH_HOST_STAGE":/srv/docs.it4i.cz/devel/$CI_BUILD_REF_NAME/
David Hrbáč's avatar
David Hrbáč committed
56

David Hrbáč's avatar
David Hrbáč committed
57
58
59
deploy to production:
  environment: production
  stage: deploy
David Hrbáč's avatar
David Hrbáč committed
60
  image: davidhrbac/docker-mkdocscheck:latest
David Hrbáč's avatar
David Hrbáč committed
61
62
63
64
65
66
67
68
69
70
71
72
  before_script:
  # install ssh-agent 
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
  - 'which rsync || ( apt-get update -y && apt-get install rsync -y )'
  # run ssh-agent
  - eval $(ssh-agent -s)
  # add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
  - ssh-add <(echo "$SSH_PRIVATE_KEY")
  # disable host key checking (NOTE: makes you susceptible to man-in-the-middle attacks)
  # WARNING: use only in docker container, if you use it with shell you will overwrite your user's ssh config
  - mkdir -p ~/.ssh
  - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config 
David Hrbáč's avatar
useradd    
David Hrbáč committed
73
  - useradd -lM nginx
David Hrbáč's avatar
David Hrbáč committed
74
  script:
David Hrbáč's avatar
David Hrbáč committed
75
  - chown nginx:nginx site -R
David Hrbáč's avatar
David Hrbáč committed
76
  - rsync -a --delete site/ root@"$SSH_HOST_STAGE":/srv/docs.it4i.cz/site/
David Hrbáč's avatar
David Hrbáč committed
77
78
79
  only:
  - master
  when: manual