.gitlab-ci.yml 3.43 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 63 64
    artifacts:
        paths:
            - ./
65
        expire_in: '1h'
66 67
    except:
        - assets
68

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

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

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

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

dump-assets:
    <<: *deploy_template
    stage: dump
124
    image: alpine:3.5
125 126 127
    artifacts:
        paths:
            - ./assets/
128
        expire_in: '3d'
129
    script:
130
      - apk add rsync --no-cache
Thomas Löffler's avatar
Thomas Löffler committed
131 132
      - 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
133 134
    dependencies:
    when:
135
    only:
136
        - assets
137
    except: