.gitlab-ci.yml 4.52 KB
Newer Older
1
variables:
2
    DOCKER_HOST: "tcp://docker-dind.gitlab-suma:2375"
3
    AUTO_DEVOPS_BUILD_IMAGE_EXTRA_ARGS: "--network host"
4 5 6 7 8 9 10 11 12 13
    POSTGRES_ENABLED: "false"
    CODE_QUALITY_DISABLED: "true"
    CONTAINER_SCANNING_DISABLED: "true"
    DAST_DISABLED: "true"
    DEPENDENCY_SCANNING_DISABLED: "true"
    LICENSE_MANAGEMENT_DISABLED: "true"
    PERFORMANCE_DISABLED: "true"
    SAST_DISABLED: "true"
    TEST_DISABLED: "true"

Dominik Hebeler's avatar
Dominik Hebeler committed
14 15
include:
  - template: Jobs/Build.gitlab-ci.yml
Dominik Hebeler's avatar
Dominik Hebeler committed
16
  - template: Jobs/Deploy.gitlab-ci.yml
Dominik Hebeler's avatar
Dominik Hebeler committed
17

18 19
stages:
  - prepare
Dominik Hebeler's avatar
Dominik Hebeler committed
20
  - build
Dominik Hebeler's avatar
Dominik Hebeler committed
21 22 23 24 25
  - deploy  # dummy stage to follow the template guidelines
  - review
  - dast
  - staging
  - canary
26
  - development
Dominik Hebeler's avatar
Dominik Hebeler committed
27 28 29 30 31
  - production
  - incremental rollout 10%
  - incremental rollout 25%
  - incremental rollout 50%
  - incremental rollout 100%
Dominik Hebeler's avatar
Dominik Hebeler committed
32
  - performance
33
  - integrationtest
Dominik Hebeler's avatar
Dominik Hebeler committed
34 35
  - cleanup

Dominik Hebeler's avatar
Dominik Hebeler committed
36 37
.auto-deploy:
  image: "registry.gitlab.com/gitlab-org/cluster-integration/auto-deploy-image:v1.0.6"
38

Dominik Hebeler's avatar
Dominik Hebeler committed
39 40 41
build:
  services:

42 43 44
prepare_node:
  stage: prepare
  image: node:10
Dominik Hebeler's avatar
Dominik Hebeler committed
45 46
  variables:
    npm_config_cache: "$CI_PROJECT_DIR/.npm"
47
  before_script:
48
    - npm install -g npm-cache
49
    - npm-cache install --cacheDirectory "$CI_PROJECT_DIR/.npm-package-cache" npm
50 51 52 53 54 55
  script:
    - npm run prod
  artifacts:
    paths:
      - public/js/
      - public/css/
Dominik Hebeler's avatar
Dominik Hebeler committed
56
      - public/mix-manifest.json
57 58
  cache:
    # Cache per Branch
Dominik Hebeler's avatar
Dominik Hebeler committed
59
    key: "metager-${CI_JOB_NAME}"
60
    paths:
Dominik Hebeler's avatar
Dominik Hebeler committed
61
      - .npm
62
      - .npm-package-cache
63
  only:
Dominik Hebeler's avatar
Dominik Hebeler committed
64 65
    - branches
    - tags
66

Dominik Hebeler's avatar
Dominik Hebeler committed
67 68
prepare_composer:
  stage: prepare
Dominik Hebeler's avatar
Dominik Hebeler committed
69
  image: registry.metager.de/open-source/composer/master
Dominik Hebeler's avatar
Dominik Hebeler committed
70 71
  variables:
    COMPOSER_HOME: "$CI_PROJECT_DIR/.composer"
Dominik Hebeler's avatar
Dominik Hebeler committed
72
  script:
73
    - composer install --no-dev
Dominik Hebeler's avatar
Dominik Hebeler committed
74 75 76 77
  artifacts:
    paths:
      - vendor
  cache:
Dominik Hebeler's avatar
Dominik Hebeler committed
78
    key: "metager-${CI_JOB_NAME}"
Dominik Hebeler's avatar
Dominik Hebeler committed
79
    paths:
80
      - .composer
Dominik Hebeler's avatar
Dominik Hebeler committed
81 82 83

review:
  variables:
Dominik Hebeler's avatar
Dominik Hebeler committed
84
    HELM_UPGRADE_VALUES_FILE: .gitlab/review-apps-values.yaml
Dominik Hebeler's avatar
Dominik Hebeler committed
85
    ROLLOUT_RESOURCE_TYPE: deployment
86 87 88 89
  environment:
    name: review/$CI_COMMIT_REF_NAME
    on_stop: stop_review
    auto_stop_in: 2 days
Dominik Hebeler's avatar
Dominik Hebeler committed
90 91 92 93 94 95 96 97 98 99
  rules:
    - if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""'
      when: never
    - if: '$CI_COMMIT_BRANCH == "master"'
      when: never
    - if: '$CI_COMMIT_BRANCH == "development"'
      when: never
    - if: '$REVIEW_DISABLED'
      when: never
    - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
100

101
stop_review:
102 103 104 105 106
  variables:
    GIT_STRATEGY: none
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: stop
Dominik Hebeler's avatar
Dominik Hebeler committed
107 108 109 110 111 112 113 114 115 116
  rules:
    - if: '$CI_KUBERNETES_ACTIVE == null || $CI_KUBERNETES_ACTIVE == ""'
      when: never
    - if: '$CI_COMMIT_BRANCH == "master"'
      when: never
    - if: '$CI_COMMIT_BRANCH == "development"'
      when: never
    - if: '$REVIEW_DISABLED'
      when: never
    - if: '$CI_COMMIT_TAG || $CI_COMMIT_BRANCH'
117 118
      when: manual

Dominik Hebeler's avatar
Dominik Hebeler committed
119

120 121 122 123 124 125 126 127 128 129 130 131 132 133

.development: &development_template
  extends: .auto-deploy
  stage: development
  script:
    - auto-deploy check_kube_domain
    - auto-deploy download_chart
    - auto-deploy ensure_namespace
    - auto-deploy initialize_tiller
    - auto-deploy create_secret
    - auto-deploy deploy
    - auto-deploy delete canary
    - auto-deploy delete rollout
    - auto-deploy persist_environment_url
Dominik Hebeler's avatar
Dominik Hebeler committed
134
  variables:
135
    ADDITIONAL_HOSTS: "www.metager3.de"
Dominik Hebeler's avatar
Dominik Hebeler committed
136 137
    HELM_UPGRADE_VALUES_FILE: .gitlab/development-values.yaml
    ROLLOUT_RESOURCE_TYPE: deployment
138 139
  environment:
    name: development
Dominik Hebeler's avatar
Dominik Hebeler committed
140
    url: https://metager3.de
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
  artifacts:
    paths: [environment_url.txt]

development:
  <<: *development_template
  only:
    refs:
      - development
    kubernetes: active
  except:
    variables:
      - $STAGING_ENABLED
      - $CANARY_ENABLED
      - $INCREMENTAL_ROLLOUT_ENABLED
      - $INCREMENTAL_ROLLOUT_MODE

Dominik Hebeler's avatar
Dominik Hebeler committed
157

Dominik Hebeler's avatar
Dominik Hebeler committed
158 159
production:
  variables:
160
    ADDITIONAL_HOSTS: "www.metager.de,metager.org,www.metager.org,metager.es,www.metager.es,klassik.metager.org"
Dominik Hebeler's avatar
Dominik Hebeler committed
161
    HELM_UPGRADE_VALUES_FILE: .gitlab/production-values.yaml
Dominik Hebeler's avatar
Dominik Hebeler committed
162 163
    ROLLOUT_RESOURCE_TYPE: deployment
  environment:
164
    url: https://metager.de
165 166 167 168 169 170 171 172 173

integrationtest:
  stage: integrationtest
  image: 
    name: prooph/composer:7.3
    entrypoint: ["/bin/sh"]
  script:
    # Install Dev Dependencies
    - composer install
174
    - cp .env.example .env
Dominik Hebeler's avatar
Dominik Hebeler committed
175
    - echo "WEBDRIVER_USER=\"$WEBDRIVER_KEY\"" >> .env
Dominik Hebeler's avatar
Dominik Hebeler committed
176 177
    - echo "WEBDRIVER_URL=\"$WEBDRIVER_URL\"" >> .env
    - echo "WEBDRIVER_KEY=\"$WEBDRIVER_USER\"" >> .env
178
    - php artisan key:generate
179 180 181 182
    - URL=$(cat environment_url.txt | tr -d '\n')
    - sed -i "s#^APP_URL=.*#APP_URL=$URL#g" .env
    - sed -i "s#^BRANCH_NAME=.*#BRANCH_NAME=$CI_COMMIT_REF_NAME#g" .env
    - sed -i "s#^COMMIT_NAME=.*#COMMIT_NAME=$CI_COMMIT_REF_SLUG#g" .env
Dominik Hebeler's avatar
Dominik Hebeler committed
183
    - php artisan dusk