.gitlab-ci.yml 2.97 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 21 22 23 24 25 26 27 28 29 30 31
test:
  stage: test
  image: php:7.0-alpine
  before_script:
    - export TYPO3_PATH_WEB="$PWD/.Build/Web"
    - export COMPOSER_CACHE_DIR=.cache/composer
    - php -r "copy('https://getcomposer.org/composer.phar', 'composer.phar');"
    - php composer.phar install
  script:
    - bin/phpunit -c .gitlab-ci/Tests/UnitTests.xml


32 33
build:
    stage: build
34
    image: php:7.0-alpine
35 36 37
    variables:
        GIT_STRATEGY: "clone"
        GIT_SUBMODULE_STRATEGY: "recursive"
38 39 40 41 42
    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
43
    script:
44 45 46
        - ./composer.phar config store-auths false
        - ./composer.phar config http-basic.git-t3o.typo3.org gitlab-ci-token ${CI_BUILD_TOKEN}
        - ./composer.phar install
47 48 49
    artifacts:
        paths:
            - ./
50
        expire_in: '1h'
51 52
    except:
        - assets
53

54 55
layout:
    stage: layout
56
    image: node:latest
57
    before_script:
58
       - cd html/typo3conf/ext/t3olayout/Build
59
    script:
60 61
       - npm install
       - npm run build
62 63 64 65
    artifacts:
        paths:
          - ./
        expire_in: '7d'
66 67
    dependencies:
        - build
68 69
    except:
        - assets
70

71
.deploy-template: &deploy_template
72
    stage: deploy
73
    image:
74
        name: "torvitas/deployer:4.0.0-alpine"
75
        entrypoint: [""]
76
    before_script:
77
        - mkdir -p /root/.ssh/
78
        - eval $(ssh-agent -s)
79 80 81
        - 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
82
        - ssh-keyscan -p 22192 extensions.typo3.org >> /root/.ssh/known_hosts
83
    script:
Thomas Löffler's avatar
Thomas Löffler committed
84
        - dep -f./.gitlab-ci/deployer/deploy.php deploy ${CI_BUILD_REF_NAME}
85 86
    dependencies:
        - layout
87 88
    except:
        - assets
89 90 91

deploy-master:
    <<: *deploy_template
92 93
    environment:
        name: master
94
        url: https://extensions.typo3.org/
95
    when: manual
96 97 98 99
    only:
        - master

deploy-develop:
100
    <<: *deploy_template
101 102
    environment:
        name: develop
103
        url: https://extensions-stage.typo3.org/
104 105
    only:
        - develop
106 107 108 109

dump-assets:
    <<: *deploy_template
    stage: dump
110
    image: alpine:3.5
111 112 113
    artifacts:
        paths:
            - ./assets/
114
        expire_in: '3d'
115
    script:
116
      - apk add rsync --no-cache
Thomas Löffler's avatar
Thomas Löffler committed
117 118
      - 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
119 120
    dependencies:
    when:
121
    only:
122
        - assets
123
    except: