t3o-builds.yml 3.97 KB
Newer Older
1
2
3
variables:
  GIT_STRATEGY: "none"
  GIT_SSL_NO_VERIFY: "true"
4
  ADDITIONAL_TABLE_EXCLUDES: ""
5

6
7
8
cache:
  key: "$CI_COMMIT_REF_NAME-$CI_JOB_STAGE"
  paths:
9
10
    - vendor/
    - private/typo3conf/ext/t3olayout/Build/node_modules/
11

12
before_script:
13
  - apk add bash --no-cache
14
15

stages:
16
17
18
19
20
  - maintenance
  - test
  - build
  - layout
  - deploy
Thomas Löffler's avatar
Thomas Löffler committed
21
  - badges
22

23
24
25
test:typoscript:
  stage: test
  image: composer:1
26
27
  variables:
    GIT_STRATEGY: "clone"
28
  before_script:
29
    - composer global require helmich/typo3-typoscript-lint --update-with-all-dependencies
30
31
32
  script:
    - /tmp/vendor/bin/typoscript-lint -c typoscript-lint.yml --fail-on-warnings

33
34
35
36
37
38
test:php:
  stage: test
  image: ekreative/php-cs-fixer:2
  variables:
    GIT_STRATEGY: "clone"
  script:
39
40
41
42
43
    - php-cs-fixer fix --dry-run --config=.gitlab-ci/build/.php_cs --diff

test:composer:
  stage: test
  image: composer:1
44
45
  variables:
    GIT_STRATEGY: "clone"
46
47
48
49
  before_script:
    - composer global require sensiolabs/security-checker
  script:
    - /tmp/vendor/bin/security-checker security:check
50
51
52

build:
  stage: build
53
  image: composer:1
54
55
56
57
  variables:
    GIT_STRATEGY: "clone"
    GIT_SUBMODULE_STRATEGY: "recursive"
  before_script:
58
59
60
61
62
    - apk add bash --no-cache
    - apk add git --update
    - export COMPOSER_CACHE_DIR=/cache/composer
    - composer config store-auths false
    - composer config http-basic.git-t3o.typo3.org gitlab-ci-token ${CI_BUILD_TOKEN}
63
  script:
64
65
66
    - composer config store-auths false
    - composer config http-basic.git-t3o.typo3.org gitlab-ci-token ${CI_BUILD_TOKEN}
    - composer install --no-dev --ignore-platform-reqs
67
68
  artifacts:
    paths:
69
      - ./
70
71
72
73
74
    expire_in: '1h'


layout:
  stage: layout
75
  image: node:12
76
  before_script:
77
    - cd private/typo3conf/ext/t3olayout/Build
78
  script:
79
80
    - npm install
    - npm run build
81
  after_script:
82
    - rm -Rf private/typo3conf/ext/t3olayout/Build/node_modules
83
84
  artifacts:
    paths:
85
      - ./
86
    expire_in: '4h'
87
  dependencies:
88
    - build
89
90
91

.deploy-template: &deploy_template
  stage: deploy
92
  image: composer:1
93
  before_script:
94
95
96
97
98
99
100
101
102
103
    - apk add rsync --update
    - mkdir -p /root/.ssh/
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY_STAGE" | ssh-add -
    - echo "$SSH_PRIVATE_KEY_PRODUCTION" | ssh-add -
    - ssh-keyscan ${STAGE_HOST} >> /root/.ssh/known_hosts
    - ssh-keyscan ${PRODUCTION_HOST} >> /root/.ssh/known_hosts
    - composer config cache-dir /cache/composer
    - composer global require deployer/deployer:6.6.0 --update-with-dependencies
    - composer global require deployer/recipes
104
  script:
105
    - /tmp/vendor/bin/dep --file=./.gitlab-ci/deployer/deploy.php deploy -vv ${CI_BUILD_REF_NAME}
106
  dependencies:
107
    - layout
108
109
110
111
112
113
114

deploy-master:
  <<: *deploy_template
  environment:
    name: master
    url: https://${PRODUCTION_HOST}
  only:
115
    - master
116
117
118
119
120
121
122

deploy-develop:
  <<: *deploy_template
  environment:
    name: develop
    url: https://${STAGE_HOST}
  only:
123
    - develop
124

125
.maintenance: &maintenance_template
126
  variables:
127
128
129
130
131
132
    GIT_STRATEGY: none
  stage: maintenance
  when: manual
  image:
    name: composer:1
    entrypoint: ["/bin/sh", "-c"]
133
  before_script:
134
135
136
137
138
139
140
141
142
143
144
    - apk add rsync --update
    - mkdir -p /root/.ssh/
    - eval $(ssh-agent -s)
    - mkdir -p ~/.ssh
    - echo "$SSH_PRIVATE_KEY_STAGE" | ssh-add -
    - ssh-keyscan ${STAGE_HOST} >> /root/.ssh/known_hosts

Get dump for local environment:
  <<: *maintenance_template
  script:
    - mkdir dump
145
    - ssh ${STAGE_USER}@${STAGE_HOST} "php ./ci/current/vendor/bin/typo3cms database:export -c Default -e 'cf_*' -e 'cache_*' -e '[bf]e_sessions' -e '[bf]e_users' -e 'sys_log' -e 'sys_history' -e 'sys_registry' -e 'tx_solr_*' -e 'tx_igldapssoauth_config' ${ADDITIONAL_TABLE_EXCLUDES} | gzip -9 -c" > ./dump/dump.sql.gz
146
147
  artifacts:
    paths:
148
149
      - ./dump/
    expire_in: 1d
Thomas Löffler's avatar
Thomas Löffler committed
150
151
152
153
154
155

"Create Badge":
  stage: badges
  script:
    - last_master_deploy=$(git --no-pager log -1 --date=format:"%Y/%m/%d-%T" --format="%ad" origin/main)
    - anybadge -l "Last Production Deployment" -v $last_master_deploy -f lastProductionDeployment.svg -c orange