.gitlab-ci.yml 2.75 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
variables:
    GIT_STRATEGY: "none"
    GIT_SSL_NO_VERIFY: "true"

before_script:
    - apk add bash --no-cache

stages:
    - dump
    - test
    - build
    - layout
    - deploy

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

build:
    stage: build
    image: php:7.0-alpine
    variables:
        GIT_STRATEGY: "clone"
        GIT_SUBMODULE_STRATEGY: "recursive"
    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
    script:
        - ./composer.phar config store-auths false
        - ./composer.phar config http-basic.git-t3o.typo3.org gitlab-ci-token ${CI_BUILD_TOKEN}
        - ./composer.phar install
    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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
    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
    image:
        name: "torvitas/deployer:4.0.0-alpine"
        entrypoint: [""]
    before_script:
        - mkdir -p /root/.ssh/
        - eval $(ssh-agent -s)
        - echo "$SSH_PRIVATE_KEY_STAGE" | ssh-add -
        - echo "$SSH_PRIVATE_KEY_PRODUCTION" | ssh-add -
        - ssh-keyscan -p 22191 my-stage.typo3.org >> /root/.ssh/known_hosts
        - ssh-keyscan -p 22193 my.typo3.org >> /root/.ssh/known_hosts
    script:
        - dep -f./.gitlab-ci/deployer/deploy.php deploy ${CI_BUILD_REF_NAME}
    dependencies:
        - layout
    except:
        - assets

deploy-master:
    <<: *deploy_template
    environment:
        name: master
        url: https://my.typo3.org/
    only:
        - master

deploy-develop:
    <<: *deploy_template
    environment:
        name: develop
        url: https://my-stage.typo3.org/
    only:
        - develop

dump-assets:
    <<: *deploy_template
    stage: dump
    image: alpine:3.5
    artifacts:
        paths:
            - ./assets/
        expire_in: '3d'
    script:
      - apk add rsync --no-cache
      - rsync -ah -e "ssh -p 22191" --exclude=typo3conf my@my-stage.typo3.org:ci/shared/ ./assets/
      - 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
    dependencies:
    when:
    tags:
        - proxy
    only:
        - assets
    except: