.gitlab-ci.yml 3.04 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
test:
  stage: test
  image: php:7.0-alpine
23 24 25
  variables:
      GIT_STRATEGY: "clone"
      GIT_SUBMODULE_STRATEGY: "recursive"
26
  before_script:
27 28 29 30
      - export TYPO3_PATH_WEB="$PWD/html"
      - export COMPOSER_CACHE_DIR=.cache/composer
      - php -r "copy('https://getcomposer.org/composer.phar', 'composer.phar');"
      - php composer.phar install
31
  script:
32
      - php composer.phar test:unit
33 34


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

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

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

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

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

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