.gitlab-ci.yml 4.54 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:
Lukáš Krupčík's avatar
Lukáš Krupčík committed
12
  - mdl -r ~MD013,~MD033,~MD014,~MD026,~MD037 *.md docs.it4i/
Lukáš Krupčík's avatar
Lukáš Krupčík committed
13

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

22 23 24 25 26
capitalize:
  stage: test
  image: davidhrbac/docker-mkdocscheck:latest
  allow_failure: true
  script:
27
  - scripts/titlemd_test.py mkdocs.yml
28 29
  - find docs.it4i/ -name '*.md' -print0 | xargs -0 -n1 scripts/titlemd_test.py

David Hrbáč's avatar
David Hrbáč committed
30 31
spell check:
  stage: test
David Hrbáč's avatar
David Hrbáč committed
32
  image: davidhrbac/docker-npmcheck:latest
David Hrbáč's avatar
David Hrbáč committed
33 34
  allow_failure: true
  script:
David Hrbáč's avatar
David Hrbáč committed
35
  #- npm i markdown-spellcheck -g
36
  - 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
37

38 39
ext_links:
  stage: test
David Hrbáč's avatar
David Hrbáč committed
40
  image: davidhrbac/docker-mdcheck:latest
41
  allow_failure: true
David Hrbáč's avatar
David Hrbáč committed
42 43
  after_script:
  - rm *.json
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
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 63
  #- apt-get update
  #- apt-get -y install git
David Hrbáč's avatar
David Hrbáč committed
64
    # add version to footer
65
  - bash scripts/add_version.sh
David Hrbáč's avatar
David Hrbáč committed
66
    # get modules list from clusters 
67
  - bash scripts/get_modules.sh
68 69
    # regenerate modules matrix
  - python scripts/modules-matrix.py > docs.it4i/modules-matrix.md
David Hrbáč's avatar
David Hrbáč committed
70
  - python scripts/modules-json.py > docs.it4i/modules-matrix.json
David Hrbáč's avatar
David Hrbáč committed
71
    # build pages
David Hrbáč's avatar
David Hrbáč committed
72
  - mkdocs build
David Hrbáč's avatar
David Hrbáč committed
73
    # compress search_index.json
74
  - bash scripts/clean_json.sh site/mkdocs/search_index.json
David Hrbáč's avatar
David Hrbáč committed
75
    # replace broken links in 404.html
76
  - sed -i 's,href="" title=",href="/" title=",g' site/404.html
David Hrbáč's avatar
David Hrbáč committed
77 78
    # compress sitemap
  - 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
David Hrbáč's avatar
David Hrbáč committed
83

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

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

David Hrbáč's avatar
David Hrbáč committed
115 116 117
deploy to production:
  environment: production
  stage: deploy
David Hrbáč's avatar
David Hrbáč committed
118
  image: davidhrbac/docker-mkdocscheck:latest
David Hrbáč's avatar
David Hrbáč committed
119 120 121 122 123 124 125 126 127 128 129 130
  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
David Hrbáč committed
131
  - useradd -lM nginx
David Hrbáč's avatar
David Hrbáč committed
132
  script:
David Hrbáč's avatar
David Hrbáč committed
133
  - chown nginx:nginx site -R
David Hrbáč's avatar
David Hrbáč committed
134
  - rsync -a --delete site/ root@"$SSH_HOST_STAGE":/srv/docs.it4i.cz/site/
David Hrbáč's avatar
David Hrbáč committed
135
  only:
136
  - master@it4i-admins/docs.it4i
David Hrbáč's avatar
David Hrbáč committed
137
  when: manual