mirror of https://github.com/hauke68/Magallanes
Andrés Montañez
10 years ago
69 changed files with 493 additions and 267 deletions
@ -0,0 +1,87 @@ |
|||||||
|
<?php |
||||||
|
/* |
||||||
|
* This file is part of the Magallanes package. |
||||||
|
* |
||||||
|
* (c) Andrés Montañez <andres@andresmontanez.com> |
||||||
|
* |
||||||
|
* For the full copyright and license information, please view the LICENSE |
||||||
|
* file that was distributed with this source code. |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace Mage\Task\BuiltIn\Scm; |
||||||
|
|
||||||
|
use Mage\Task\AbstractTask; |
||||||
|
use Mage\Task\SkipException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Task for Force Updating a Working Copy |
||||||
|
* |
||||||
|
* 'git fetch' downloads the latest from remote without trying to merge or rebase anything. |
||||||
|
* 'git reset' resets the master branch to what you just fetched. |
||||||
|
* The '--hard' option changes all the files in your working tree to match the files in origin/master, |
||||||
|
* so if you have any local changes, they will be lost. |
||||||
|
* |
||||||
|
* @author Samuel Chiriluta <samuel4x4@gmail.com> |
||||||
|
*/ |
||||||
|
class ForceUpdateTask extends AbstractTask |
||||||
|
{ |
||||||
|
/** |
||||||
|
* Name of the Task |
||||||
|
* @var string |
||||||
|
*/ |
||||||
|
private $name = 'SCM Force Update [built-in]'; |
||||||
|
|
||||||
|
/** |
||||||
|
* (non-PHPdoc) |
||||||
|
* @see \Mage\Task\AbstractTask::getName() |
||||||
|
*/ |
||||||
|
public function getName() |
||||||
|
{ |
||||||
|
return $this->name; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* (non-PHPdoc) |
||||||
|
* @see \Mage\Task\AbstractTask::init() |
||||||
|
*/ |
||||||
|
public function init() |
||||||
|
{ |
||||||
|
switch ($this->getConfig()->general('scm')) { |
||||||
|
case 'git': |
||||||
|
$this->name = 'SCM Force Update (GIT) [built-in]'; |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Force Updates the Working Copy |
||||||
|
* @see \Mage\Task\AbstractTask::run() |
||||||
|
*/ |
||||||
|
public function run() |
||||||
|
{ |
||||||
|
switch ($this->getConfig()->general('scm')) { |
||||||
|
case 'git': |
||||||
|
$branch = $this->getParameter('branch', 'master'); |
||||||
|
$remote = $this->getParameter('remote', 'origin'); |
||||||
|
|
||||||
|
$command = 'git fetch ' . $remote . ' ' . $branch; |
||||||
|
$result = $this->runCommandRemote($command); |
||||||
|
|
||||||
|
$command = 'git reset --hard ' . $remote . '/' . $branch; |
||||||
|
$result = $result && $this->runCommandRemote($command); |
||||||
|
|
||||||
|
$command = 'git pull ' . $remote . ' ' . $branch; |
||||||
|
$result = $result && $this->runCommandRemote($command); |
||||||
|
break; |
||||||
|
|
||||||
|
default: |
||||||
|
throw new SkipException; |
||||||
|
break; |
||||||
|
} |
||||||
|
|
||||||
|
$result = $this->runCommandLocal($command); |
||||||
|
$this->getConfig()->reload(); |
||||||
|
|
||||||
|
return $result; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
<?php |
||||||
|
/* |
||||||
|
* This file is part of the Magallanes package. |
||||||
|
* |
||||||
|
* (c) Andrés Montañez <andres@andresmontanez.com> |
||||||
|
* |
||||||
|
* For the full copyright and license information, please view the LICENSE |
||||||
|
* file that was distributed with this source code. |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace Mage\Task\BuiltIn\Symfony2; |
||||||
|
|
||||||
|
use Mage\Task\BuiltIn\Symfony2\SymfonyAbstractTask; |
||||||
|
|
||||||
|
/** |
||||||
|
* Task for Doctrine migrations |
||||||
|
*/ |
||||||
|
class DoctrineMigrate extends SymfonyAbstractTask |
||||||
|
{ |
||||||
|
/** |
||||||
|
* (non-PHPdoc) |
||||||
|
* @see \Mage\Task\AbstractTask::getName() |
||||||
|
*/ |
||||||
|
public function getName() |
||||||
|
{ |
||||||
|
return 'Symfony v2 - Migrate doctrine entities [built-in]'; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Migrates Doctrine entities |
||||||
|
* |
||||||
|
* @see \Mage\Task\AbstractTask::run() |
||||||
|
*/ |
||||||
|
public function run() |
||||||
|
{ |
||||||
|
$env = $this->getParameter('env', 'dev'); |
||||||
|
$command = $this->getAppPath() . ' doctrine:migrations:migrate -n --env=' . $env; |
||||||
|
return $this->runCommand($command); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,23 @@ |
|||||||
|
<?php |
||||||
|
/* |
||||||
|
* This file is part of the Magallanes package. |
||||||
|
* |
||||||
|
* (c) Alex V Kotelnikov <gudron@gudron.me> |
||||||
|
* |
||||||
|
* For the full copyright and license information, please view the LICENSE |
||||||
|
* file that was distributed with this source code. |
||||||
|
*/ |
||||||
|
|
||||||
|
namespace Mage\Task; |
||||||
|
|
||||||
|
use Exception; |
||||||
|
|
||||||
|
/** |
||||||
|
* Exception that indicates that the Task was Failed and rollback needed |
||||||
|
* |
||||||
|
* @author Alex V Kotelnikov <gudron@gudron.me> |
||||||
|
*/ |
||||||
|
class RollbackException extends Exception |
||||||
|
{ |
||||||
|
|
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
{ |
||||||
|
"files": ["LICENSE"], |
||||||
|
"finder": [ |
||||||
|
{ |
||||||
|
"name": "*.php", |
||||||
|
"exclude": [ |
||||||
|
"docs" |
||||||
|
], |
||||||
|
"in": "Mage" |
||||||
|
} |
||||||
|
], |
||||||
|
"git-version": "git_tag", |
||||||
|
"main": "bin/mage", |
||||||
|
"output": "mage.phar", |
||||||
|
"stub": true |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
#production |
||||||
|
deployment: |
||||||
|
user: root |
||||||
|
from: ./ |
||||||
|
# source: |
||||||
|
# type: git |
||||||
|
# repository: git://github.com/andres-montanez/Magallanes.git |
||||||
|
# from: master |
||||||
|
# temporal: /tmp/myAppClone |
||||||
|
to: /var/www/vhosts/example.com/www |
||||||
|
excludes: |
||||||
|
- application/data/cache/twig/* |
||||||
|
releases: |
||||||
|
enabled: true |
||||||
|
max: 5 |
||||||
|
symlink: current |
||||||
|
directory: releases |
||||||
|
hosts: |
||||||
|
- s01.example.com |
||||||
|
- s02.example.com |
||||||
|
# s02.example.com: |
||||||
|
# deployment: |
||||||
|
# user: toor |
||||||
|
# to: /home/web/public |
||||||
|
# releases: |
||||||
|
# max: 10 |
||||||
|
# tasks: |
||||||
|
# on-deploy: |
||||||
|
# - privileges |
||||||
|
tasks: |
||||||
|
pre-deploy: |
||||||
|
- scm/update |
||||||
|
on-deploy: |
||||||
|
- symfony2/cache-warmup: { env: prod } |
||||||
|
- privileges |
||||||
|
- sampleTask |
||||||
|
- sampleTaskRollbackAware |
||||||
|
#post-deploy: |
Loading…
Reference in new issue