-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d40a43c
Showing
22 changed files
with
954 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
.DS_store | ||
.idea/ | ||
vendor/ | ||
stub/ | ||
composer.phar | ||
config.yml | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
language: php | ||
|
||
php: | ||
- '5.3' | ||
- '5.4' | ||
- '5.5' | ||
- '5.6' | ||
- '7.0' | ||
- '7.1' | ||
|
||
before_script: | ||
- composer install | ||
|
||
script: | ||
phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Deployment assistant | ||
[![Build Status](https://travis-ci.org/worksolutions/deployment-assistant.svg?branch=master)](https://travis-ci.org/worksolutions/deployment-assistant) | ||
|
||
[Russian](README.ru.md) | ||
|
||
Assistant safe deployment on production server. | ||
|
||
|
||
## Install | ||
|
||
Assistant is an executable phar-archive. | ||
To install, enter the command: | ||
|
||
```bash | ||
php -r "copy('http://dep.worksolutions.ru/dep.phar', 'dep.phar');" | ||
chmod +x ./dep.phar | ||
``` | ||
|
||
Assistant phar-archive is downloaded and saved in your current directory. | ||
|
||
Assistant supports php versions from 5.3 to 7.1 | ||
|
||
|
||
## Usage | ||
|
||
### Deploy | ||
|
||
Deployment command will check the state of the production and remote branches. | ||
After a successful check, you will receive the changes from the remote branch to the production. | ||
|
||
|
||
Syntax for the deployment command is: | ||
|
||
```bash | ||
php ./dep.phar deploy [<remote>] [<branch>] | ||
``` | ||
|
||
To start deploy, type: | ||
|
||
```bash | ||
php ./dep.phar deploy | ||
``` | ||
|
||
By default, changes will pull from the remote branch `origin/master`, | ||
to change it is required to specify from which branch of the remote source | ||
you need to pull the changes: | ||
|
||
```bash | ||
php ./dep.phar deploy origin master | ||
``` | ||
|
||
### Update | ||
|
||
Update command will check if there is a new version of the helper and, | ||
if there is one, will update it. | ||
|
||
```bash | ||
php ./dep.phar self-update | ||
``` | ||
|
||
## Contributing | ||
|
||
To make a contribution to the assistant - send pool-requests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Deployment assistant | ||
[![Build Status](https://travis-ci.org/worksolutions/deployment-assistant.svg?branch=master)](https://travis-ci.org/worksolutions/deployment-assistant) | ||
|
||
[English](README.md) | ||
|
||
Помощник безопасного развертывания с git на боевом сервере. | ||
|
||
## Установка | ||
|
||
Помощник является исполняемым phar-архивом. | ||
Для установки введите команду: | ||
|
||
```bash | ||
php -r "copy('http://dep.worksolutions.ru/dep.phar', 'dep.phar');" | ||
chmod +x ./dep.phar | ||
``` | ||
|
||
Phar-архив помощника скачается и сохранится в вашей текущей директории. | ||
|
||
Помощник поддерживает версии php от 5.3 до 7.1 | ||
|
||
## Использование | ||
|
||
### Развертывание | ||
|
||
Команда развертывания проверит состояние локальной и удаленной веток. | ||
После успешной проверки выполнит получение изменений из удаленной в локальную ветку. | ||
|
||
Синтаксис команды развертывания: | ||
|
||
```bash | ||
php ./dep.phar deploy [<remote>] [<branch>] | ||
``` | ||
|
||
Для запуска процесса развертывания введите: | ||
|
||
```bash | ||
php ./dep.phar deploy | ||
``` | ||
|
||
По умолчанию изменения вытянутся из удаленной ветки `origin/master`, | ||
чтобы изменить требуется указать из какой ветки удаленного источника | ||
нужно вытянуть изменения: | ||
|
||
```bash | ||
php ./dep.phar deploy origin master | ||
``` | ||
|
||
### Обновление | ||
|
||
Команда обновления проверит есть ли новая версия помощника и, если есть – обновит его. | ||
|
||
```bash | ||
php ./dep.phar self-update | ||
``` | ||
|
||
## Внести вклад | ||
|
||
Чтобы внести вклад в инструмент – используйте пул-реквесты. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$app = new \WS\DeploymentAssistant\Application(); | ||
$app->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"blacklist": [], | ||
"directories": [ | ||
"src", | ||
"bin", | ||
"vendor" | ||
], | ||
"files": [ | ||
"config.yml" | ||
], | ||
"main": "bin/main.php", | ||
"output": "build/dep.phar", | ||
"chmod": "0755", | ||
"stub": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"autoload": { | ||
"psr-4": { | ||
"WS\\DeploymentAssistant\\": "src", | ||
"WS\\DeploymentAssistant\\Tests\\": "tests/src" | ||
} | ||
}, | ||
"require": { | ||
"roave/security-advisories": "dev-master", | ||
"symfony/console": "^2.8", | ||
"symfony/process": "^2.8", | ||
"symfony/config": "^2.8", | ||
"symfony/yaml": "^2.8", | ||
"symfony/event-dispatcher": "^2.8", | ||
"sentry/sentry": "^1.7" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^4.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
update: | ||
phar_url: "http://host/dep.phar" | ||
sum_url: "http://host/dep.md5.txt" | ||
|
||
sentry: | ||
dsn: "https://key:[email protected]/project" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="tests/bootstrap.php" | ||
> | ||
<testsuites> | ||
<testsuite name="Deploy Assistant Test Suite"> | ||
<directory>./tests/src/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace WS\DeploymentAssistant; | ||
use Symfony\Component\Config\Definition\Processor; | ||
use Symfony\Component\Console\ConsoleEvents; | ||
use Symfony\Component\EventDispatcher\EventDispatcher; | ||
use Symfony\Component\Yaml\Yaml; | ||
use WS\DeploymentAssistant\Commands\DeployCommand; | ||
use WS\DeploymentAssistant\Commands\SelfUpdateCommand; | ||
use WS\DeploymentAssistant\Helpers\GitHelper; | ||
use WS\DeploymentAssistant\Helpers\SentryHelper; | ||
use WS\DeploymentAssistant\Helpers\VersionHelper; | ||
use WS\DeploymentAssistant\Listeners\SentryExceptionListener; | ||
|
||
/** | ||
* Class Application | ||
* @package WS\DeployAssistant | ||
*/ | ||
class Application extends \Symfony\Component\Console\Application | ||
{ | ||
public function __construct($exceptionHandling = true, $version = 'UNKNOWN') | ||
{ | ||
parent::__construct('Deployment assistant', $version); | ||
|
||
$config = $this->getConfig(); | ||
|
||
$this->getHelperSet()->set(new GitHelper()); | ||
$this->getHelperSet()->set(new SentryHelper($config['sentry']['dsn'])); | ||
$this->getHelperSet()->set(new VersionHelper( | ||
$config['update']['phar_url'], | ||
$config['update']['sum_url'])); | ||
|
||
$this->addCommands(array( | ||
new DeployCommand(), | ||
new SelfUpdateCommand() | ||
)); | ||
|
||
if ($exceptionHandling) { | ||
$dispatcher = new EventDispatcher(); | ||
$dispatcher->addListener(ConsoleEvents::EXCEPTION, new SentryExceptionListener()); | ||
|
||
$this->setDispatcher($dispatcher); | ||
} | ||
} | ||
|
||
/** | ||
* @return array | ||
* @throws \Symfony\Component\Yaml\Exception\ParseException | ||
*/ | ||
private function getConfig() | ||
{ | ||
$path = dirname(__DIR__) . '/config.yml'; | ||
if (!file_exists($path)) { | ||
$path = dirname(__DIR__) . '/config.example.yml'; | ||
} | ||
|
||
$config = Yaml::parse( | ||
file_get_contents($path) | ||
); | ||
|
||
$processor = new Processor(); | ||
$configuration = new Configuration(); | ||
return $processor->processConfiguration( | ||
$configuration, | ||
array($config) | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.