.gitlab-ci.yml 2.75 KB
Newer Older
1 2 3 4 5 6 7 8 9
variables:
    GIT_STRATEGY: "none"
    GIT_SSL_NO_VERIFY: "true"

before_script:
    - apk add bash --no-cache

stages:
    - dump
10
    - test
11 12 13 14
    - build
    - layout
    - deploy

15 16 17 18 19 20 21 22 23 24
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

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


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

.deploy-template: &deploy_template
    stage: deploy
67 68 69
    image:
        name: "torvitas/deployer:4.0.0-alpine"
        entrypoint: [""]
70
    before_script:
71
        - mkdir -p /root/.ssh/
72 73 74
        - eval $(ssh-agent -s)
        - echo "$SSH_PRIVATE_KEY_STAGE" | ssh-add -
        - echo "$SSH_PRIVATE_KEY_PRODUCTION" | ssh-add -
75 76
        - ssh-keyscan -p 22191 my-stage.typo3.org >> /root/.ssh/known_hosts
        - ssh-keyscan -p 22193 my.typo3.org >> /root/.ssh/known_hosts
77
    script:
Thomas Löffler's avatar
Thomas Löffler committed
78
        - dep -f./.gitlab-ci/deployer/deploy.php deploy ${CI_BUILD_REF_NAME}
79 80 81 82 83 84 85 86 87
    dependencies:
        - layout
    except:
        - assets

deploy-master:
    <<: *deploy_template
    environment:
        name: master
88
        url: https://my.typo3.org/
89 90 91 92 93 94 95
    only:
        - master

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

dump-assets:
    <<: *deploy_template
    stage: dump
    image: alpine:3.5
    artifacts:
        paths:
            - ./assets/
        expire_in: '3d'
    script:
      - apk add rsync --no-cache
110
      - rsync -ah -e "ssh -p 22191" --exclude=typo3conf my@my-stage.typo3.org:ci/shared/ ./assets/
111
      - ssh -p22191 my@my-stage.typo3.org "mysqldump -u${STAGE_DATABASE_USER} -p${STAGE_DATABASE_PASSWORD} -h127.0.0.1 ${STAGE_DATABASE_DB} | gzip -9 -c" > ./assets/db.sql.gz
112 113 114 115 116 117 118
    dependencies:
    when:
    tags:
        - proxy
    only:
        - assets
    except: