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

David Hrbáč's avatar
David Hrbáč committed
7 8 9
variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

Lukáš Krupčík's avatar
Lukáš Krupčík committed
10 11
docs:
  stage: test
12
  image: it4innovations/docker-mdcheck:latest
David Hrbáč's avatar
David Hrbáč committed
13
  allow_failure: true
Lukáš Krupčík's avatar
Lukáš Krupčík committed
14
  script:
15
  - mdl -r ~MD013,~MD010,~MD014,~MD024,~MD026,~MD029,~MD033,~MD036,~MD037,~MD046 *.md docs.it4i # BUGS
Lukáš Krupčík's avatar
Lukáš Krupčík committed
16

17 18
capitalize:
  stage: test
19
  image: it4innovations/docker-mkdocscheck:latest
20
  script:
21
  - find mkdocs.yml docs.it4i/ \( -name '*.md' -o -name '*.yml' \) -print0 | xargs -0 -n1 scripts/titlemd_test.py
22

23 24
ext_links:
  stage: test
25
  image: it4innovations/docker-mdcheck:latest
26
  allow_failure: true
David Hrbáč's avatar
David Hrbáč committed
27
  after_script:
Pavel Gajdušek's avatar
Pavel Gajdušek committed
28
  # remove JSON results
David Hrbáč's avatar
David Hrbáč committed
29
  - rm *.json
David Hrbáč's avatar
David Hrbáč committed
30 31
  script:
  - find docs.it4i/ -name '*.md' -exec grep --color -l http {} + | xargs awesome_bot -t 10 --allow-dupe --allow-redirect
32 33 34
  only:
  - master

David Hrbáč's avatar
David Hrbáč committed
35
404s:
David Hrbáč's avatar
David Hrbáč committed
36
  stage: after_test
37
  image: it4innovations/docker-mkdocscheck:latest
David Hrbáč's avatar
David Hrbáč committed
38
  before_script:
David Hrbáč's avatar
David Hrbáč committed
39 40
  - wget -V
  - echo https://docs.it4i.cz/devel/$CI_BUILD_REF_NAME/
David Hrbáč's avatar
David Hrbáč committed
41
  - wget --spider -e robots=off -o wget.log -r -p https://docs.it4i.cz/devel/$CI_BUILD_REF_NAME/ || true
David Hrbáč's avatar
David Hrbáč committed
42
  script:
David Hrbáč's avatar
David Hrbáč committed
43
  - cat wget.log | awk '/^Found [0-9]+ broken link[s]?.$/,/FINISHED/ { rc=-1; print $0 }; END { exit rc }'
David Hrbáč's avatar
David Hrbáč committed
44

45
mkdocs:
David Hrbáč's avatar
David Hrbáč committed
46
  stage: build
47
  image: it4innovations/docker-mkdocscheck:latest
David Hrbáč's avatar
David Hrbáč committed
48 49 50 51
  cache:
    paths:
      - .cache/pip
      - venv/
David Hrbáč's avatar
David Hrbáč committed
52
  before_script:
David Hrbáč's avatar
David Hrbáč committed
53 54 55
  - python -V               # Print out python version for debugging
  - virtualenv venv
  - source venv/bin/activate
David Hrbáč's avatar
David Hrbáč committed
56
  - pip install -r requirements.txt
57
  script:
David Hrbáč's avatar
David Hrbáč committed
58
  - mkdocs -V
David Hrbáč's avatar
David Hrbáč committed
59
    # add version to footer
60
  - bash scripts/add_version.sh
Pavel Gajdušek's avatar
Pavel Gajdušek committed
61
    # get modules list from clusters
62
  - bash scripts/get_modules.sh
David Hrbáč's avatar
David Hrbáč committed
63
    # generate site_url
David Hrbáč's avatar
David Hrbáč committed
64
  - (if [ "${CI_BUILD_REF_NAME}" != 'master' ]; then sed -i "s/\(site_url.*$\)/\1devel\/$CI_BUILD_REF_NAME\//" mkdocs.yml;fi);
David Hrbáč's avatar
David Hrbáč committed
65
    # generate ULT for code link
David Hrbáč's avatar
David Hrbáč committed
66
  - sed -i "s/master/$CI_BUILD_REF_NAME/g" material/partials/toc.html
67 68
    # regenerate modules matrix
  - python scripts/modules-matrix.py > docs.it4i/modules-matrix.md
69
  - python scripts/modules-json.py > docs.it4i/modules-matrix.json
David Hrbáč's avatar
David Hrbáč committed
70
  - curl -f0 https://code.it4i.cz/sccs/scs-api-public/raw/master/scs_api.server_public.md -o docs.it4i/apiv1.md
David Hrbáč's avatar
David Hrbáč committed
71
    # build pages
72
  - mkdocs build
David Hrbáč's avatar
David Hrbáč committed
73
    # replace broken links in 404.html
74
  - sed -i 's,href="" title=",href="/" title=",g' site/404.html
David Hrbáč's avatar
David Hrbáč committed
75
  - cp site/404.html site/403.html
David Hrbáč's avatar
David Hrbáč committed
76
  - sed -i 's/404 - Not found/403 - Forbidden/g' site/403.html
David Hrbáč's avatar
David Hrbáč committed
77
    # compress sitemap
Pavel Gajdušek's avatar
Pavel Gajdušek committed
78
  - gzip < site/sitemap.xml > site/sitemap.xml.gz
David Hrbáč's avatar
David Hrbáč committed
79 80 81 82
  artifacts:
    paths:
    - site
    expire_in: 1 week
83

David Hrbáč's avatar
David Hrbáč committed
84
deploy to stage:
Pavel Gajdušek's avatar
Pavel Gajdušek committed
85
  environment: stage
David Hrbáč's avatar
David Hrbáč committed
86
  stage: deploy
87
  image: it4innovations/docker-mkdocscheck:latest
David Hrbáč's avatar
David Hrbáč committed
88
  before_script:
Pavel Gajdušek's avatar
Pavel Gajdušek committed
89
  # install ssh-agent
David Hrbáč's avatar
David Hrbáč committed
90
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
David Hrbáč's avatar
David Hrbáč committed
91
  - 'which rsync || ( apt-get update -y && apt-get install rsync -y )'
David Hrbáč's avatar
David Hrbáč committed
92 93 94 95 96 97
  # 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
98
  - mkdir -p ~/.ssh
David Hrbáč's avatar
David Hrbáč committed
99
  - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
David Hrbáč's avatar
David Hrbáč committed
100
  script:
David Hrbáč's avatar
David Hrbáč committed
101
  - chown nginx:nginx site -R
David Hrbáč's avatar
David Hrbáč committed
102
  - rsync -a --delete site/ root@"$SSH_HOST_STAGE":/srv/docs.it4i.cz/devel/$CI_BUILD_REF_NAME/
103
  only:
David Hrbáč's avatar
David Hrbáč committed
104
  - branches@sccs/docs.it4i.cz
David Hrbáč's avatar
David Hrbáč committed
105

David Hrbáč's avatar
David Hrbáč committed
106
deploy to production:
David Hrbáč's avatar
David Hrbáč committed
107
  environment: production
David Hrbáč's avatar
David Hrbáč committed
108
  stage: deploy
109
  image: it4innovations/docker-mkdocscheck:latest
David Hrbáč's avatar
David Hrbáč committed
110
  before_script:
Pavel Gajdušek's avatar
Pavel Gajdušek committed
111
  # install ssh-agent
David Hrbáč's avatar
David Hrbáč committed
112 113 114 115 116 117 118 119 120
  - '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
Pavel Gajdušek's avatar
Pavel Gajdušek committed
121
  - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
David Hrbáč's avatar
David Hrbáč committed
122
  script:
David Hrbáč's avatar
David Hrbáč committed
123
  - chown nginx:nginx site -R
David Hrbáč's avatar
David Hrbáč committed
124
  - rsync -a --delete site/ root@"$SSH_HOST_STAGE":/srv/docs.it4i.cz/site/
David Hrbáč's avatar
David Hrbáč committed
125
  only:
David Hrbáč's avatar
David Hrbáč committed
126
  - master@sccs/docs.it4i.cz
David Hrbáč's avatar
David Hrbáč committed
127
  when: manual