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

Lukáš Krupčík's avatar
Lukáš Krupčík committed
6
7
8
9
docs:
  stage: test
  image: davidhrbac/docker-mdcheck:latest
  script:
Lukáš Krupčík's avatar
add scp    
Lukáš Krupčík committed
10
  - mdl -r ~MD013,~MD033,~MD014,~MD026,~MD037,~MD036,~MD010,~MD029 *.md docs.it4i
Lukáš Krupčík's avatar
Lukáš Krupčík committed
11

Lukáš Krupčík's avatar
Lukáš Krupčík committed
12
13
14
15
16
17
18
19
20
#two spaces:
#  stage: test
#  image: davidhrbac/docker-mdcheck:latest
#  allow_failure: true
#  before_script:
#  - echo "== Files having more than one space betwee two characters =="
#  - find docs.it4i/ -name '*.md' ! -path "docs.it4i/software*" -exec grep -nr "[[:alpha:]]  [[:alpha:]]" -l {} +
#  script:
#  - find docs.it4i/ -name '*.md' ! -path "docs.it4i/software*" -exec grep -nr "[[:alpha:]]  [[:alpha:]]" -l {} +
David Hrbáč's avatar
David Hrbáč committed
21

22
23
24
capitalize:
  stage: test
  image: davidhrbac/docker-mkdocscheck:latest
25
  # allow_failure: true
26
  script:
David Hrbáč's avatar
David Hrbáč committed
27
  - find mkdocs.yml docs.it4i/ \( -name '*.md' -o -name '*.yml' \) -print0 | xargs -0 -n1 scripts/titlemd_test.py
28

David Hrbáč's avatar
David Hrbáč committed
29
30
spell check:
  stage: test
David Hrbáč's avatar
David Hrbáč committed
31
  image: davidhrbac/docker-npmcheck:latest
David Hrbáč's avatar
David Hrbáč committed
32
33
  allow_failure: true
  script:
David Hrbáč's avatar
David Hrbáč committed
34
  #- npm i markdown-spellcheck -g
35
  - mdspell '**/*.md' '!docs.it4i/module*.md' '!docs.it4i/anselm-cluster-documentation/software/omics-master/overview.md' '!docs.it4i/downtimes_history.md' -rns --en-us
David Hrbáč's avatar
David Hrbáč committed
36

David Hrbáč's avatar
David Hrbáč committed
37
38
ext_links:
  stage: test
David Hrbáč's avatar
David Hrbáč committed
39
  image: davidhrbac/docker-mdcheck:latest
David Hrbáč's avatar
David Hrbáč committed
40
  allow_failure: true
David Hrbáč's avatar
David Hrbáč committed
41
  after_script:
Pavel Gajdušek's avatar
mdlint    
Pavel Gajdušek committed
42
  # remove JSON results
David Hrbáč's avatar
David Hrbáč committed
43
  - rm *.json
David Hrbáč's avatar
David Hrbáč committed
44
  script:
45
  #- find docs.it4i/ -name '*.md' -exec grep --color -l http {} + | xargs awesome_bot -t 10
David Hrbáč's avatar
David Hrbáč committed
46
  - find docs.it4i/ -name '*.md' -exec grep --color -l http {} + | xargs awesome_bot -t 10 --allow-dupe --allow-redirect
David Hrbáč's avatar
David Hrbáč committed
47
48
49
50
51
52
53
54
  #- |
  #  COMMIT_MESSAGE=$(git log -1 --pretty=%B | grep "Merge branch 'hot_fix' into 'master'" )
  #  if [[ ${COMMIT_MESSAGE} == *hot_fix* ]]; then
  #    echo "Skipping ci build"
  #    exit 0
  #  else
  #    find docs.it4i/ -name '*.md' ! -name 'modules-*.md' -exec grep --color -l http {} + | xargs awesome_bot -t 10 --allow-dupe --allow-redirect
  #  fi
David Hrbáč's avatar
David Hrbáč committed
55
56
57
  only:
  - master

David Hrbáč's avatar
David Hrbáč committed
58
mkdocs:
David Hrbáč's avatar
David Hrbáč committed
59
  stage: build
David Hrbáč's avatar
David Hrbáč committed
60
61
  image: davidhrbac/docker-mkdocscheck:latest
  script:
David Hrbáč's avatar
David Hrbáč committed
62
  - mkdocs -V
David Hrbáč's avatar
David Hrbáč committed
63
64
  #- apt-get update
  #- apt-get -y install git
David Hrbáč's avatar
David Hrbáč committed
65
    # add version to footer
66
  - bash scripts/add_version.sh
Pavel Gajdušek's avatar
mdlint    
Pavel Gajdušek committed
67
    # get modules list from clusters
68
  - bash scripts/get_modules.sh
69
70
    # regenerate modules matrix
  - python scripts/modules-matrix.py > docs.it4i/modules-matrix.md
David Hrbáč's avatar
David Hrbáč committed
71
  - python scripts/modules-json.py > docs.it4i/modules-matrix.json
David Hrbáč's avatar
David Hrbáč committed
72
  - 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
73
    # build pages
David Hrbáč's avatar
David Hrbáč committed
74
  - mkdocs build
David Hrbáč's avatar
David Hrbáč committed
75
    # compress search_index.json
David Hrbáč's avatar
David Hrbáč committed
76
    #- bash scripts/clean_json.sh site/mkdocs/search_index.json
David Hrbáč's avatar
David Hrbáč committed
77
    # replace broken links in 404.html
78
  - sed -i 's,href="" title=",href="/" title=",g' site/404.html
David Hrbáč's avatar
David Hrbáč committed
79
  - cp site/404.html site/403.html
David Hrbáč's avatar
David Hrbáč committed
80
  - sed -i 's/404 - Not found/403 - Forbidden/g' site/403.html
David Hrbáč's avatar
David Hrbáč committed
81
    # compress sitemap
Pavel Gajdušek's avatar
mdlint    
Pavel Gajdušek committed
82
  - gzip < site/sitemap.xml > site/sitemap.xml.gz
David Hrbáč's avatar
David Hrbáč committed
83
84
85
86
  artifacts:
    paths:
    - site
    expire_in: 1 week
David Hrbáč's avatar
David Hrbáč committed
87

Lukáš Krupčík's avatar
Lukáš Krupčík committed
88
89
90
shellcheck:
  stage: test
  image: davidhrbac/docker-shellcheck:latest
David Hrbáč's avatar
David Hrbáč committed
91
  allow_failure: true
Lukáš Krupčík's avatar
Lukáš Krupčík committed
92
93
  script:
  - which shellcheck || apt-get update && apt-get install -y shellcheck
David Hrbáč's avatar
David Hrbáč committed
94
  - find . -name *.sh -not -path "./docs.it4i/*" -not -path "./site/*" -exec shellcheck {} +
David Hrbáč's avatar
David Hrbáč committed
95

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

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