.gitlab-ci.yml 1.06 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
image: composer:1

cache:
  paths:
    - docs/cache/
    - vendor/

stages:
  - test
  - build
  - deploy

build:
  stage: build
  script:
    - composer install
    - sh sbin/generate_documentation.sh

test:
  stage: test
  before_script:
    - cp .php_cs.dist .php_cs
  script:
    - sh sbin/php-cs-fixer.sh --dry-run --diff

deploy:
  stage: deploy
  variables:
    REMOTE_HOST: "${REMOTE_USER}@${REMOTE_HOSTNAME}"
  before_script:
    # Remote target configuration
    - cp remote.env.dist remote.env
    - sed -i "s|TARGET_HOST=.*|TARGET_HOST=$REMOTE_HOST|g" remote.env
    - sed -i "s|TARGET_PATH=.*|TARGET_PATH=$REMOTE_PATH|g" remote.env
    - sed -i "s|TARGET_PORT=.*|TARGET_PORT=$REMOTE_PORT|g" remote.env
    - cat remote.env

    # Environment configuration
    - apk add rsync --update
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | ssh-add -
    - ssh-keyscan -p ${REMOTE_PORT} ${REMOTE_HOSTNAME} >> ~/.ssh/known_hosts
  script:
    - find . -type d -exec chmod 755 {} \;
    - sh sbin/deploy.sh
  only:
    - master