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

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

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

deploy-master:
    <<: *deploy_template
98 99
    environment:
        name: master
100
        url: https://extensions.typo3.org/
101 102 103 104
    only:
        - master

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

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