.gitlab-ci.yml 4.61 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 12
docs:
  stage: test
  image: davidhrbac/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:
Lukáš Krupčík's avatar
Lukáš Krupčík committed
15
  - mdl -r ~MD024,~MD013,~MD033,~MD014,~MD026,~MD037,~MD036,~MD010,~MD029 *.md docs.it4i # BUGS
Lukáš Krupčík's avatar
Lukáš Krupčík committed
16

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

Lukáš Krupčík's avatar
Lukáš Krupčík committed
24 25 26 27 28 29 30
    #spell check:
    #stage: test
    #image: davidhrbac/docker-npmcheck:latest
    #allow_failure: true
    #script:
    #- npm i markdown-spellcheck -g
    #- mdspell '**/*.md' '!docs.it4i/module*.md' -rns --en-us
31

32 33
ext_links:
  stage: test
David Hrbáč's avatar
David Hrbáč committed
34
  image: davidhrbac/docker-mdcheck:latest
35
  allow_failure: true
David Hrbáč's avatar
David Hrbáč committed
36
  after_script:
Pavel Gajdušek's avatar
Pavel Gajdušek committed
37
  # remove JSON results
David Hrbáč's avatar
David Hrbáč committed
38
  - rm *.json
David Hrbáč's avatar
David Hrbáč committed
39 40
  script:
  - find docs.it4i/ -name '*.md' -exec grep --color -l http {} + | xargs awesome_bot -t 10 --allow-dupe --allow-redirect
41 42 43
  only:
  - master

David Hrbáč's avatar
David Hrbáč committed
44
404s:
David Hrbáč's avatar
David Hrbáč committed
45
  stage: after_test
David Hrbáč's avatar
David Hrbáč committed
46 47
  image: davidhrbac/docker-mkdocscheck:latest
  script:
David Hrbáč's avatar
David Hrbáč committed
48 49
  - wget -V
  - echo https://docs.it4i.cz/devel/$CI_BUILD_REF_NAME/
David Hrbáč's avatar
David Hrbáč committed
50 51
  - wget --spider -e robots=off -o wget.log -r -p https://docs.it4i.cz/devel/$CI_BUILD_REF_NAME/
  - cat wget.log | awk '/^Found [0-9]+ broken links.$/,/FINISHED/ { rc=-1; print $0 }; END { exit rc }'
David Hrbáč's avatar
David Hrbáč committed
52

53
mkdocs:
David Hrbáč's avatar
David Hrbáč committed
54
  stage: build
55
  image: davidhrbac/docker-mkdocscheck:latest
David Hrbáč's avatar
David Hrbáč committed
56 57 58 59
  cache:
    paths:
      - .cache/pip
      - venv/
David Hrbáč's avatar
David Hrbáč committed
60
  before_script:
David Hrbáč's avatar
David Hrbáč committed
61 62 63 64
  - python -V               # Print out python version for debugging
  - pip install virtualenv
  - virtualenv venv
  - source venv/bin/activate
David Hrbáč's avatar
David Hrbáč committed
65
  - pip install -r requirements.txt
66
  script:
David Hrbáč's avatar
David Hrbáč committed
67
  - mkdocs -V
David Hrbáč's avatar
David Hrbáč committed
68
    # add version to footer
69
  - bash scripts/add_version.sh
Pavel Gajdušek's avatar
Pavel Gajdušek committed
70
    # get modules list from clusters
71
  - bash scripts/get_modules.sh
David Hrbáč's avatar
David Hrbáč committed
72
    # generate site_url
David Hrbáč's avatar
David Hrbáč committed
73
  - (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
74
    # generate ULT for code link
David Hrbáč's avatar
David Hrbáč committed
75
  - sed -i "s/master/$CI_BUILD_REF_NAME/g" material/partials/toc.html
76 77
    # regenerate modules matrix
  - python scripts/modules-matrix.py > docs.it4i/modules-matrix.md
78
  - python scripts/modules-json.py > docs.it4i/modules-matrix.json
David Hrbáč's avatar
David Hrbáč committed
79
  - curl -f0 https://scs-test.it4i.cz/devel/apidocs/master/scs_api.server_public.md -o docs.it4i/apiv1.md
David Hrbáč's avatar
David Hrbáč committed
80
    # build pages
81
  - mkdocs build
David Hrbáč's avatar
David Hrbáč committed
82
    # compress search_index.json
David Hrbáč's avatar
David Hrbáč committed
83
    #- bash scripts/clean_json.sh site/mkdocs/search_index.json
David Hrbáč's avatar
David Hrbáč committed
84
    # replace broken links in 404.html
85
  - sed -i 's,href="" title=",href="/" title=",g' site/404.html
David Hrbáč's avatar
David Hrbáč committed
86
  - cp site/404.html site/403.html
David Hrbáč's avatar
David Hrbáč committed
87
  - sed -i 's/404 - Not found/403 - Forbidden/g' site/403.html
David Hrbáč's avatar
David Hrbáč committed
88
    # compress sitemap
Pavel Gajdušek's avatar
Pavel Gajdušek committed
89
  - gzip < site/sitemap.xml > site/sitemap.xml.gz
David Hrbáč's avatar
David Hrbáč committed
90 91 92 93
  artifacts:
    paths:
    - site
    expire_in: 1 week
94

David Hrbáč's avatar
David Hrbáč committed
95
deploy to stage:
Pavel Gajdušek's avatar
Pavel Gajdušek committed
96
  environment: stage
David Hrbáč's avatar
David Hrbáč committed
97
  stage: deploy
David Hrbáč's avatar
David Hrbáč committed
98
  image: davidhrbac/docker-mkdocscheck:latest
David Hrbáč's avatar
David Hrbáč committed
99
  before_script:
Pavel Gajdušek's avatar
Pavel Gajdušek committed
100
  # install ssh-agent
David Hrbáč's avatar
David Hrbáč committed
101
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
David Hrbáč's avatar
David Hrbáč committed
102
  - 'which rsync || ( apt-get update -y && apt-get install rsync -y )'
David Hrbáč's avatar
David Hrbáč committed
103 104 105 106 107 108
  # 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
109
  - mkdir -p ~/.ssh
David Hrbáč's avatar
David Hrbáč committed
110
  - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
David Hrbáč's avatar
David Hrbáč committed
111
  - useradd -lM nginx
David Hrbáč's avatar
David Hrbáč committed
112
  script:
David Hrbáč's avatar
David Hrbáč committed
113
  - chown nginx:nginx site -R
David Hrbáč's avatar
David Hrbáč committed
114
  - rsync -a --delete site/ root@"$SSH_HOST_STAGE":/srv/docs.it4i.cz/devel/$CI_BUILD_REF_NAME/
115
  only:
David Hrbáč's avatar
David Hrbáč committed
116
  - branches@sccs/docs.it4i.cz
David Hrbáč's avatar
David Hrbáč committed
117

David Hrbáč's avatar
David Hrbáč committed
118
deploy to production:
David Hrbáč's avatar
David Hrbáč committed
119
  environment: production
David Hrbáč's avatar
David Hrbáč committed
120
  stage: deploy
David Hrbáč's avatar
David Hrbáč committed
121
  image: davidhrbac/docker-mkdocscheck:latest
David Hrbáč's avatar
David Hrbáč committed
122
  before_script:
Pavel Gajdušek's avatar
Pavel Gajdušek committed
123
  # install ssh-agent
David Hrbáč's avatar
David Hrbáč committed
124 125 126 127 128 129 130 131 132
  - '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
133
  - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
David Hrbáč's avatar
David Hrbáč committed
134
  - useradd -lM nginx
David Hrbáč's avatar
David Hrbáč committed
135
  script:
David Hrbáč's avatar
David Hrbáč committed
136
  - chown nginx:nginx site -R
David Hrbáč's avatar
David Hrbáč committed
137
  - rsync -a --delete site/ root@"$SSH_HOST_STAGE":/srv/docs.it4i.cz/site/
David Hrbáč's avatar
David Hrbáč committed
138
  only:
David Hrbáč's avatar
David Hrbáč committed
139
  - master@sccs/docs.it4i.cz
David Hrbáč's avatar
David Hrbáč committed
140
  when: manual