.gitlab-ci.yml 3.06 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 30 31
      - 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
32
  script:
33
      - php composer.phar test:unit
34 35


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

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

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

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

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

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