.gitlab-ci.yml 4 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

36

Dominik Hebeler's avatar
Dominik Hebeler committed
37 38 39
build:
  services:

40 41 42 43 44 45 46 47 48 49 50
prepare_node:
  stage: prepare
  image: node:10
  before_script:
    - npm install
  script:
    - npm run prod
  artifacts:
    paths:
      - public/js/
      - public/css/
Dominik Hebeler's avatar
Dominik Hebeler committed
51
      - public/mix-manifest.json
52 53 54 55 56 57
  cache:
    # Cache per Branch
    key: "node-$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"
    paths:
      - node_modules
  only:
Dominik Hebeler's avatar
Dominik Hebeler committed
58 59
    - branches
    - tags
60

Dominik Hebeler's avatar
Dominik Hebeler committed
61 62 63 64
prepare_composer:
  stage: prepare
  image: prooph/composer:7.3
  script:
65
    - composer install --no-dev
Dominik Hebeler's avatar
Dominik Hebeler committed
66 67 68 69 70 71
  artifacts:
    paths:
      - vendor
  cache:
    key: "composer-$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"
    paths:
Dominik Hebeler's avatar
Dominik Hebeler committed
72 73 74 75
      - vendor

review:
  variables:
Dominik Hebeler's avatar
Dominik Hebeler committed
76
    HELM_UPGRADE_VALUES_FILE: .gitlab/review-apps-values.yaml
Dominik Hebeler's avatar
Dominik Hebeler committed
77
    ROLLOUT_RESOURCE_TYPE: deployment
Dominik Hebeler's avatar
Dominik Hebeler committed
78 79 80 81 82 83 84 85 86 87
  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'
88

89
stop_review:
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
      when: manual

Dominik Hebeler's avatar
Dominik Hebeler committed
102

103 104 105 106 107 108 109 110 111 112 113 114 115 116

.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
117
  variables:
118
    ADDITIONAL_HOSTS: "www.metager3.de"
Dominik Hebeler's avatar
Dominik Hebeler committed
119 120
    HELM_UPGRADE_VALUES_FILE: .gitlab/development-values.yaml
    ROLLOUT_RESOURCE_TYPE: deployment
121 122
  environment:
    name: development
Dominik Hebeler's avatar
Dominik Hebeler committed
123
    url: https://metager3.de
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
  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
140

Dominik Hebeler's avatar
Dominik Hebeler committed
141 142
production:
  variables:
143
    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
144
    HELM_UPGRADE_VALUES_FILE: .gitlab/production-values.yaml
Dominik Hebeler's avatar
Dominik Hebeler committed
145 146
    ROLLOUT_RESOURCE_TYPE: deployment
  environment:
147
    url: https://metager.de
148 149 150 151 152 153 154 155 156

integrationtest:
  stage: integrationtest
  image: 
    name: prooph/composer:7.3
    entrypoint: ["/bin/sh"]
  script:
    # Install Dev Dependencies
    - composer install
157
    - cp .env.example .env
Dominik Hebeler's avatar
Dominik Hebeler committed
158
    - echo "WEBDRIVER_USER=\"$WEBDRIVER_KEY\"" >> .env
Dominik Hebeler's avatar
Dominik Hebeler committed
159 160
    - echo "WEBDRIVER_URL=\"$WEBDRIVER_URL\"" >> .env
    - echo "WEBDRIVER_KEY=\"$WEBDRIVER_USER\"" >> .env
161
    - php artisan key:generate
162 163 164 165
    - 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
166
    - php artisan dusk