.gitlab-ci.yml 1.5 KB
Newer Older
Felix Flor's avatar
Felix Flor committed
1 2 3 4 5 6
before_script:
  - mkdir -p ~/.ssh

stages:
  - build
  - deploy
Felix Flor's avatar
Felix Flor committed
7
  - post_deploy
Felix Flor's avatar
Felix Flor committed
8 9

build_phar:
Felix Flor's avatar
Felix Flor committed
10 11 12 13
  artifacts:
    expire_in: 1 week
    paths:
      - aphpbreakdown-*.phar
Felix Flor's avatar
Felix Flor committed
14 15
  stage: build
  only:
Felix Flor's avatar
Felix Flor committed
16
    - tags
Felix Flor's avatar
Felix Flor committed
17 18 19 20 21 22 23 24 25 26
  tags:
    - PHP
    - PHAR
  script:
    - php buildPhar.php
    - mv aphpbreakdown.phar aphpbreakdown-$CI_COMMIT_TAG.phar

deploying:
  stage: deploy
  only:
Felix Flor's avatar
Felix Flor committed
27
    - tags
Felix Flor's avatar
Felix Flor committed
28 29 30 31
  tags:
    - rsync
  script:
    - eval $(ssh-agent -s)
Felix Flor's avatar
Felix Flor committed
32
    - ssh-add <(echo "$DEPLOY_PRIVATE_KEY")
33
    - rsync -rpvu --progress ./aphpbreakdown-*.phar $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PHAR_PATH
Felix Flor's avatar
Felix Flor committed
34
    - killall ssh-agent
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

deploy_version:
  stage: deploy
  only:
    - tags
  tags:
    - rsync
  script:
    - if [ -f ./latest.php ]; then
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$DEPLOY_PRIVATE_KEY")
    - rsync -rpvu --progress ./latest.php $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_VERSION_PATH
    - killall ssh-agent
    - fi

deploy_changelog:
  stage: deploy
  only:
    - tags
  tags:
    - rsync
  script:
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$DEPLOY_PRIVATE_KEY")
    - rsync -rpvu --progress ./CHANGELOG.md $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_VERSION_PATH
    - killall ssh-agent

build_symlink:
  stage: post_deploy
  only:
    - tags
  tags:
    - rsync
  script:
    - if [ -f ./latest.php ]; then
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$DEPLOY_PRIVATE_KEY")
Felix Flor's avatar
Felix Flor committed
72
    - ssh $DEPLOY_USER@$DEPLOY_HOST "ln -s -f "$DEPLOY_PHAR_PATH"aphpbreakdown-"$CI_COMMIT_TAG".phar "$DEPLOY_PHAR_PATH"aphpbreakdown.phar"
73 74
    - killall ssh-agent
    - fi