.gitlab-ci.yml 3.46 KB
Newer Older
Thomas Löffler's avatar
Thomas Löffler committed
1
cache:
2
  key: "$CI_COMMIT_REF_NAME-$CI_JOB_STAGE"
Thomas Löffler's avatar
Thomas Löffler committed
3
  paths:
4
    - /composer
Thomas Löffler's avatar
Thomas Löffler committed
5

6 7
variables:
    GIT_STRATEGY: "none"
8
    GIT_SSL_NO_VERIFY: "true"
9

10
before_script:
11
    - apk add bash --no-cache
12

13
stages:
14
    - dump
15
    - test
16
    - build
17
    - layout
18 19
    - deploy

20
test:unit:
21 22
  stage: test
  image: php:7.0-alpine
23 24 25
  variables:
      GIT_STRATEGY: "clone"
      GIT_SUBMODULE_STRATEGY: "recursive"
26
  before_script:
Tomas Norre Mikkelsen's avatar
Tomas Norre Mikkelsen committed
27
      - apk add git --update
28 29
      - export TYPO3_PATH_WEB="$PWD/html"
      - export COMPOSER_CACHE_DIR=.cache/composer
30 31
      - curl https://getcomposer.org/composer.phar -o composer.phar --silent
      - chmod +x composer.phar
32
      - ./composer.phar install
33
      - mkdir $TYPO3_PATH_WEB/fileadmin/ && touch $TYPO3_PATH_WEB/fileadmin/currentcoredata.json
34
  script:
35
      - ./composer.phar test:unit
36

37 38 39 40 41 42 43 44 45
test:php:
    stage: test
    image: ekreative/php-cs-fixer:2
    variables:
        GIT_STRATEGY: "clone"
    script:
        - php-cs-fixer fix --dry-run --config=.gitlab-ci/build/.php_cs --diff
    except:
        - assets
46

47 48
build:
    stage: build
49
    image: php:7.0-alpine
50 51 52
    variables:
        GIT_STRATEGY: "clone"
        GIT_SUBMODULE_STRATEGY: "recursive"
53 54 55 56 57
    before_script:
        - apk add bash --no-cache
        - apk add git --update
        - curl https://getcomposer.org/composer.phar -o composer.phar --silent
        - chmod +x composer.phar
58
    script:
59 60
        - ./composer.phar config store-auths false
        - ./composer.phar config http-basic.git-t3o.typo3.org gitlab-ci-token ${CI_BUILD_TOKEN}
61
        - ./composer.phar install --no-interaction --no-progress --no-dev
62
        - rm composer.phar
63 64 65
    artifacts:
        paths:
            - ./
66
        expire_in: '1h'
67 68
    except:
        - assets
69

70 71
layout:
    stage: layout
72
    image: node:latest
73
    before_script:
74
       - cd private/typo3conf/ext/t3olayout/Build
75
    script:
76 77
       - npm install
       - npm run build
78 79 80 81
    artifacts:
        paths:
          - ./
        expire_in: '7d'
82 83
    dependencies:
        - build
84 85
    except:
        - assets
86

87
.deploy-template: &deploy_template
88
    stage: deploy
89
    image:
90
        name: "torvitas/deployer:4.0.0-alpine"
91
        entrypoint: [""]
92
    before_script:
93
        - mkdir -p /root/.ssh/
94
        - eval $(ssh-agent -s)
95 96 97
        - echo "$SSH_PRIVATE_KEY_STAGE" | ssh-add -
        - echo "$SSH_PRIVATE_KEY_PRODUCTION" | ssh-add -
        - ssh-keyscan -p 22191 extensions-stage.typo3.org >> /root/.ssh/known_hosts
98
        - ssh-keyscan -p 22192 extensions.typo3.org >> /root/.ssh/known_hosts
99
    script:
Thomas Löffler's avatar
Thomas Löffler committed
100
        - dep -f./.gitlab-ci/deployer/deploy.php deploy ${CI_BUILD_REF_NAME}
101 102
    dependencies:
        - layout
103 104
    except:
        - assets
105 106 107

deploy-master:
    <<: *deploy_template
108 109
    environment:
        name: master
110
        url: https://extensions.typo3.org/
111 112 113 114
    only:
        - master

deploy-develop:
115
    <<: *deploy_template
116 117
    environment:
        name: develop
118
        url: https://extensions-stage.typo3.org/
119 120
    only:
        - develop
121 122 123 124

dump-assets:
    <<: *deploy_template
    stage: dump
125
    image: alpine:3.5
126 127 128
    artifacts:
        paths:
            - ./assets/
129
        expire_in: '3d'
130
    script:
131
      - apk add rsync --no-cache
Thomas Löffler's avatar
Thomas Löffler committed
132 133
      - rsync -ah -e "ssh -p 22191" extensionsstage@extensions-stage.typo3.org:ci/shared/ ./assets/
      - ssh -p22191 extensionsstage@extensions-stage.typo3.org "mysqldump -u${DEV_DATABASE_USER} -p${DEV_DATABASE_PASSWORD} -h127.0.0.1 extensionsstage | gzip -9 -c" > ./assets/db.sql.gz
134 135
    dependencies:
    when:
136
    only:
137
        - assets
138
    except: