Skip to content

Commit

Permalink
Adds deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
heiglandreas committed Mar 19, 2016
1 parent 740fd61 commit 79d9738
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 27 deletions.
6 changes: 6 additions & 0 deletions .deploy/deploy_exclude.property
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.*
doc
build
logs
tests
src/config/settings.php
11 changes: 11 additions & 0 deletions .deploy/deploy_include.property
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
LICENSE
README.md
src/**
config/dependencies.php
config/middleware.php
config/routes.php
config/settings.php.ini
database/**
public/**
templates/**
vendor/**
2 changes: 2 additions & 0 deletions .deploy/deploy_post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
find /home/phpug/php.ug/src/public/ -maxdepth 1 -mindepth 1 -type d -exec cp -r {} /home/phpug/html/ \;
58 changes: 31 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
sudo: false
language: php

matrix:
fast_finish: true
include:
- php: 5.5
- php: 5.6
- php: 7
env:
- EXECUTE_CS_CHECK=true
- EXECUTE_TEST_COVERALLS=true
- php: hhvm
- php: nightly
- php: hhvm-nightly

- php: 5.5
- php: 5.6
- php: 7
env:
- EXECUTE_CS_CHECK=true
- EXECUTE_TEST_COVERALLS=true
- php: hhvm
- php: nightly
- php: hhvm-nightly
allow_failures:
- php: 5.5
- php: hhvm
- php: nightly
- php: hhvm-nightly

- php: 5.5
- php: hhvm
- php: nightly
- php: hhvm-nightly
before_install:
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- composer self-update
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update satooshi/php-coveralls ; fi

- if [ $TRAVIS_BRANCH == "master" ] && [ $EXECUTE_TEST_COVERALLS == 'true' ] ; then
openssl aes-256-cbc -K $encrypted_13cee3189705_key -iv $encrypted_13cee3189705_iv
-in deploy-key.enc -out deploy-key -d && chmod 600 deploy-key; fi
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then phpenv config-rm xdebug.ini ||
return 0 ; fi
- composer self-update
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then composer require --dev --no-update
satooshi/php-coveralls ; fi
install:
- travis_retry composer install --no-interaction --ignore-platform-reqs

- travis_retry composer install --no-interaction --ignore-platform-reqs
script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit -c phpunit.travis.xml --coverage-clover clover.xml ; fi
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit -c phpunit.travis.xml; fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff --dry-run ; fi

- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/phpunit -c phpunit.travis.xml
--coverage-clover clover.xml ; fi
- if [[ $EXECUTE_TEST_COVERALLS != 'true' ]]; then ./vendor/bin/phpunit -c phpunit.travis.xml;
fi
- if [[ $EXECUTE_CS_CHECK == 'true' ]]; then ./vendor/bin/php-cs-fixer fix -v --diff
--dry-run ; fi
after_script:
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi
- if [[ $EXECUTE_TEST_COVERALLS == 'true' ]]; then ./vendor/bin/coveralls ; fi
- if [ $TRAVIS_BRANCH == "master" ] && [ $EXECUTE_TEST_COVERALLS == 'true' ] ; then
./vendor/bin/phing deploy; fi
34 changes: 34 additions & 0 deletions build.property
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
;; Propertyfile for phing
;;
;;
; deploy.target
deploy.target = 37.139.26.154
;
; deploy.user
deploy.user = deploy
;
; deployLocation
deploy.location = /var/www/com.callingallpapers.cli/
;
; deploy.post_deploy_script
; the script will be called relative to the deploy.path
;deploy.post_deploy_script = deploy_post.sh
;
; deploy.local_folder
deploy.local_folder = deploy
;
;
;deploy.pre_deploy_script = deploy_pre.sh
;
; deploy.method
; can be one of
; copy - Copy the stuff via scp to the server
; sync - Sync the stuff cia rsync to the server.
deploy.method = sync
;
;
deploy.path_to_rsync = /usr/bin/rsync
;
;
deploy.identity_file = deploy-key

143 changes: 143 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* $Id$
*
* Copyright (c) 2008-2011 Andreas Heigl<andreas@heigl.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* This is the ant-buildfile
*
* @category php.ug
* @package php.ug
* @author Andreas Heigl <andreas@heigl.org>
* @copyright 2012 Andreas Heigl<andreas@heigl.org>
* @license http://www.opensource.org/licenses/mit-license.php MIT-License
* @version 0.0
* @since 06.03.2012
*/
-->
<project name="callingallpapers-cli" default="build" basedir=".">

<property file="./build.property"/>
<property file="./build.property.dist"/>

<target name="update">
<echo message="Updating composer-binary"/>
<exec command="composer self-update"/>
<echo message="Updating Requirements"/>
<exec command="composer update --no-dev" />
</target>

<target name="test">
<phpunit configuration="phpunit.xml.dist">
<formatter type = "plain" usefile = "false"/>
<batchtest>
<fileset dir = "src/module/Phpug/tests">
<include name = "**/*Test*.php"/>
</fileset>
</batchtest>
</phpunit>
</target>

<target name="build">

</target>

<target name="updatePhp">
<composer command="install"/>
</target>

<target name="updateAssets">
<exec command="bower install"/>
</target>

<target name="createDeployFolder">
<echo>Creating Deployment-Folder</echo>
<mkdir dir="${deploy.local_folder}" />
<copy todir="${deploy.local_folder}">
<fileset dir="." excludesfile=".deploy/deploy_exclude.property" includesfile=".deploy/deploy_include.property" />
</copy>
</target>

<target name="copyDeployFolderToServer">
<echo>Copying files to target ${deploy.target}</echo>
<exec command="ssh -i ${deploy.identity_file} ${deploy.user}@${deploy.target} 'mkdir -p ${deploy.location}'" />
<exec dir="${deploy.local_folder}" command="scp -i ${deploy.identity_file} -rv ./* ${deploy.user}@${deploy.target}:${deploy.location}" />
</target>

<target name="syncDeployFolderToServer">
<echo>Creating location ${deploy.location} on the server</echo>
<exec command="ssh -o StrictHostKeyChecking=no -i ${deploy.identity_file} ${deploy.user}@${deploy.target} 'mkdir -p ${deploy.location}'" />
<echo>Synching files to target ${deploy.target}</echo>
<filesync destinationDir="${deploy.user}@${deploy.target}:${deploy.location}"
rsyncPath="${deploy.path_to_rsync}"
sourceDir="${deploy.local_folder}/."
checksum="true"
options="-e 'ssh -o StrictHostKeyChecking=no -i ${deploy.identity_file}' -aKz"
/>
</target>

<target name="callPostDeployScriptOnServer">
<echo>Calling post-deploy-script on target ${deploy.target}</echo>
<exec command="ssh -i ${deploy.identity_file} ${deploy.user}@${deploy.target} '${deploy.location}/${deploy.post_deploy_script}'"/>
</target>

<target name="callPreDeployScriptOnServer" >
<available property="deploy.pre_deploy_script_exists" file="${deploy.local_folder}/${deploy.pre_deploy_script}"/>
<if>
<isset property="deploy.pre_deploy_script_exists"/>
<then>
<echo>Calling pre-deploy-script on target ${deploy.target}</echo>
<loadfile property="deploy.pre_deploy_script_content" file="${deploy.local_folder}/${deploy.pre_deploy_script}"/>
<exec command="ssh -i ${deploy.identity_file} ${deploy.user}@${deploy.target} '${deploy.pre_deploy_script_content}'"/>
</then>
</if>
</target>

<target name="deployFolderToServer">
<if>
<equals arg1="sync" arg2="${deploy.method}"/>
<then>
<phingcall inheritAll="true" target="syncDeployFolderToServer"/>
</then>
<elseif>
<equals arg1="copy" arg2="${deploy.method}"/>
<then>
<phingcall target="copyDeployFolderToServer" inheritAll="true"/>
</then>
</elseif>
</if>
</target>

<target name="removeDeployFolder">
<delete dir="${deploy.local_folder}" includeemptydirs="true"/>
</target>

<target name="deploy" depends="update, updateAssets">
<echo>Deploying application</echo>
<phingcall inheritAll="true" target="createDeployFolder"/>
<phingcall inheritAll="true" target="callPreDeployScriptOnServer"/>
<phingcall inheritAll="true" target="deployFolderToServer"/>
<phingcall inheritAll="true" target="callPostDeployScriptOnServer"/>
<phingcall inheritAll="true" target="removeDeployFolder"/>
</target>

</project>
Binary file added deploy-key.enc
Binary file not shown.

0 comments on commit 79d9738

Please sign in to comment.