Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #93 from niels-nijens/documentation
Browse files Browse the repository at this point in the history
Added documentation
  • Loading branch information
niels-nijens committed Jan 8, 2016
2 parents 8075047 + a4a4c92 commit bac52c7
Show file tree
Hide file tree
Showing 14 changed files with 368 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Force Unix line-endings
* text eol=lf
*.png binary

# Remove all test and documentation files from releases with 'export-ignore'.
/docs export-ignore
Expand Down
54 changes: 50 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Accompli

[![Latest Version on Packagist][ico-version]][link-version]
[![Latest version on Packagist][ico-version]][link-version]
[![Latest pre-release version on Packagist][ico-pre-release-version]][link-version]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-build]][link-build]
[![Coverage Status][ico-coverage]][link-coverage]
Expand All @@ -13,26 +14,70 @@ An easy to use and extendable deployment tool for PHP projects.
## Installation using Composer

Run the following command to add the package to your composer.json:
Run the following command to add the package to the composer.json of your project:

``` bash
$ composer require accompli/accompli
$ composer require accompli/accompli:dev-master --dev
```

#### Versioning
Accompli uses [Semantic Versioning 2](http://semver.org/) for new versions.

## Usage
1. Create an accompli.json defining the hosts to deploy to and the tasks to run during install and deployment.

*Note that this example might not work for your project.*

``` json
{
"$extend": "vendor/accompli/accompli/src/Resources/accompli-defaults.json",
"hosts": [
{
"stage": "test",
"connectionType": "ssh",
"hostname": "example.com",
"path": "/var/www/example.com"
}
],
"events": {
"subscribers": [
{
"class": "Accompli\\Task\\CreateWorkspaceTask"
},
{
"class": "Accompli\\Task\\RepositoryCheckoutTask",
"repositoryUrl": "https://github.com/example.com/example.com.git"
},
{
"class": "Accompli\\Task\\DeployReleaseTask"
},
{
"class": "Accompli\\Task\\MaintenanceModeTask"
}
]
}
}
```

2. Run Accompli to install a release of your project: `vendor/bin/accompli install-release <version>`

3. Run Accompli to deploy an installed release of your project: `vendor/bin/accompli deploy-release <version> <stage>`

For a more detailed description on how to use Accompli, please see the [getting started][link-documentation] page.

## Credits and acknowledgements

- [Niels Nijens][link-author]
- [Reyo Stallenberg][link-author-name] \(creator of the name 'Accompli'\)
- [All Contributors][link-contributors]

Also see the list of [contributors][link-contributors] who participated in this project.

## License

Accompli is licensed under the MIT License. Please see the [LICENSE file](LICENSE.md) for details.

[ico-version]: https://img.shields.io/packagist/v/accompli/accompli.svg
[ico-pre-release-version]: https://img.shields.io/packagist/vpre/accompli/accompli.svg
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg
[ico-build]: https://travis-ci.org/accompli/accompli.svg?branch=master
[ico-coverage]: https://coveralls.io/repos/accompli/accompli/badge.svg?branch=master
Expand All @@ -44,6 +89,7 @@ Accompli is licensed under the MIT License. Please see the [LICENSE file](LICENS
[link-coverage]: https://coveralls.io/r/accompli/accompli?branch=master
[link-security]: https://insight.sensiolabs.com/projects/5b884e85-bb11-4847-b212-e3aaace39a26
[link-code-style]: https://styleci.io/repos/32416744
[link-documentation]: https://github.com/accompli/accompli/docs/Getting-started.md
[link-author]: https://github.com/niels-nijens
[link-author-name]: https://github.com/reyostallenberg
[link-contributors]: https://github.com/accompli/accompli/contributors
Expand Down
107 changes: 107 additions & 0 deletions docs/01-Getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Getting started

Accompli is a tool to automate deployment of (PHP) projects. It allows you to easily configure (and create) a set of tasks
and run the task when deploying a release of your project.

We aim provide support for [Testing-Acceptance-Production][link-wikipedia-dtap], [Continuous Delivery][link-wikipedia-continuous-delivery] and [Continuous Deployment][link-wikipedia-continuous-delivery] concepts.

## Why the name 'Accompli'?

Accompli is the French word for 'accomplished' or 'finished'.
This fits well with deploying your project, as it most likely to be done.
The French originates back to when Accompli was mainly meant to be a deployment tool for
Symfony Framework projects. Which is created by SensioLabs, a French company.

## System Requirements

Accompli requires PHP 5.4.0+ to run.

The following extensions are suggested to speed up SSH related tasks:
* mcrypt
* openssl

In order to install releases from version control, you will need to have git or subversion
installed depending on how your project is version-controlled.

Accompli is multi-platform and we strive to make it run equally well on Windows, Linux and OSX.

## Installation using Composer

Run the following command to add the package to the composer.json of your project:

``` bash
$ composer require accompli/accompli:dev-master --dev
```

## Using Accompli

In order for Accompli to run you require a accompli.json file in the root of your project.
This will contain the configured hosts to deploy to and the tasks to run during deployment of a release.

An example accompli.json:
``` json
{
"$extend": "vendor/accompli/accompli/src/Resources/accompli-defaults.json",
"hosts": [
{
"stage": "test",
"connectionType": "ssh",
"hostname": "example.com",
"path": "/var/www/example.com"
}
],
"events": {
"subscribers": [
{
"class": "Accompli\\Task\\CreateWorkspaceTask"
},
{
"class": "Accompli\\Task\\RepositoryCheckoutTask",
"repositoryUrl": "https://github.com/example.com/example.com.git"
},
{
"class": "Accompli\\Task\\DeployReleaseTask"
},
{
"class": "Accompli\\Task\\MaintenanceModeTask"
}
]
}
}
```

For more detailed information on how to configure your accompli.json, please see the [configuration](Configuration.md) documentation.

See the [tasks](Tasks.md) documentation to learn what tasks are provided by Accompli and how to create your own tasks.

### Install a release for deployment
To install a release for deployment you need to run the following command from your project root:

``` bash
$ vendor/bin/accompli install-release <version>
```

Accompli will then run the configured installation tasks for all configured hosts.

Optionally, you can install a release on hosts with a specific stage configured:

``` bash
$ vendor/bin/accompli install-release <version> <stage>
```

### Deploy a release

To deploy a previously install release you need to run the following command from your project root:

``` bash
$ vendor/bin/accompli deploy-release <version> <stage>
```

During a deployment Accompli is able to determine wether the deployment is a rollback to a previous version or an increment to a new version.

*C'est fini! Accompli!*


[link-wikipedia-dtap]: https://en.wikipedia.org/wiki/Development,_testing,_acceptance_and_production
[link-wikipedia-continuous-delivery]: https://en.wikipedia.org/wiki/Continuous_delivery
[link-wikipedia-continuous-deployment]: https://en.wikipedia.org/wiki/Continuous_deployment
105 changes: 105 additions & 0 deletions docs/02-Configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Configuration
This chapter will explain all the available sections of the accompli.json configuration.

## Using a recipe
A recipe is a set of pre-configured tasks defined in a separate accompli.json file.

You can include a recipe by referencing it in the '$extend' key:
``` json
{
"$extend": "vendor/accompli/accompli/src/Resources/accompli-defaults.json"
}
```

The path to the recipe can be relative to the location of the accompli.json in your project.

## Configuring a host

Hosts are configured in an array within the 'hosts' key.

A host object requires the following keys:
* stage - The deployment stage a host is part of (test, acceptance, production).
* connectionType - The identifier of a connection adapter to communicate with the host.
* hostname - The IP address or DNS hostname of the host.
* path - The absolute path to the workspace on the host.

``` json
{
"hosts": [
{
"stage": "test",
"connectionType": "ssh",
"hostname": "example.com",
"path": "/var/www/example.com"
}
]
}
```

Optionally, a 'connectionOptions' key can be configured within a host object with an array of connection adapter specific configuration parameters.

For more information on the specific connection options, please see the [connection adapter](Connection-adapters.md) documentation.

## Configuring a task

Tasks are mostly configured as an event subscriber, but can also be configured as event listener for a specific event.

To configure a task as an event subscriber add your class to the 'events.subscribers' keys:

``` json
{
"events": {
"subscribers": [
{
"class": "My\\Namespaced\\Task"
}
]
}
}
```

If your task has constructor arguments to configure it's behavior, you're able to configure them next to the class name of the task:

``` json
{
"events": {
"subscribers": [
{
"class": "My\\Namespaced\\Task",
"argument1": "value",
"argument2": 2
}
]
}
}
```

For more information about tasks and a list of available Accompli tasks, see the [tasks](Tasks.md) documentation.

## Configuring the deployment strategy

A deployment strategy is configured in the 'deployment.strategy' keys by setting the class name:

``` json
{
"deployment": {
"strategy": "Accompli\\Deployment\\Strategy\\RemoteInstallStrategy"
}
}
```

## Configuring connection adapters

Connection adapters are configured in the 'deployment.connection' keys with a unique identifier and the class name of the connection adapter:

``` json
{
"deployment": {
"connection": {
"uniqueIdentifier": "My\\Namespaced\\ConnectionAdapter"
}
}
}
```

The identifier can then be used to configure the 'connectionType' key of a host.
36 changes: 26 additions & 10 deletions docs/Tasks.md → docs/03-Tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

A task consists of one or more installation and/or deployment actions. They execute the actions by listening to events dispatched by the [Symfony Event Dispatcher][link-symfony-event-dispatcher] service.

## Available tasks

The following tasks are included in Accompli:

### Install tasks

* [CreateWorkspaceTask](tasks/CreateWorkspaceTask.md)
* [RepositoryCheckoutTask](tasks/RepositoryCheckoutTask.md)

### Deployment tasks

* [MaintenanceModeTask](tasks/MaintenanceModeTask.md)
* [DeployReleaseTask](tasks/DeployReleaseTask.md)

## Creating a task

A task can be either an Event Listener or an Event Subscriber. For reusability it's easier for users to configure a task that is self-aware of the events it needs to listen to than configure each event listener separately.
Expand Down Expand Up @@ -39,9 +53,9 @@ class ExampleTask extends AbstractConnectedTask
/**
* Do something by using the connection adapter.
*
* @param PrepareWorkspaceEvent $event
* @param WorkspaceEvent $event
*/
public function onPrepareWorkspaceDoSomething(PrepareWorkspaceEvent $event)
public function onPrepareWorkspaceDoSomething(WorkspaceEvent $event)
{
$connection = $this->ensureConnection($event->getHost());

Expand Down Expand Up @@ -75,18 +89,20 @@ Some dispatched events differ per scenario.
##### Deployment of a new release

1. AccompliEvents::CREATE_CONNECTION
2. AccompliEvents::PREPARE_DEPLOY_RELEASE
3. AccompliEvents::DEPLOY_RELEASE
4. AccompliEvents::DEPLOY_RELEASE_COMPLETE (dispatched only when the deployment of a release was completed successfully)
5. AccompliEvents::DEPLOY_RELEASE_FAILED (dispatched only when eg. a certain task fails)
2. AccompliEvents::GET_WORKSPACE
3. AccompliEvents::PREPARE_DEPLOY_RELEASE
4. AccompliEvents::DEPLOY_RELEASE
5. AccompliEvents::DEPLOY_RELEASE_COMPLETE (dispatched only when the deployment of a release was completed successfully)
6. AccompliEvents::DEPLOY_RELEASE_FAILED (dispatched only when eg. a certain task fails)

##### Rollback deployment to an old release

1. AccompliEvents::CREATE_CONNECTION
2. AccompliEvents::PREPARE_DEPLOY_RELEASE
3. AccompliEvents::ROLLBACK_RELEASE
4. AccompliEvents::ROLLBACK_RELEASE_COMPLETE (dispatched only when the deployment of a release was completed successfully)
5. AccompliEvents::ROLLBACK_RELEASE_FAILED (dispatched only when eg. a certain task fails)
2. AccompliEvents::GET_WORKSPACE
3. AccompliEvents::PREPARE_DEPLOY_RELEASE
4. AccompliEvents::ROLLBACK_RELEASE
5. AccompliEvents::ROLLBACK_RELEASE_COMPLETE (dispatched only when the deployment of a release was completed successfully)
6. AccompliEvents::ROLLBACK_RELEASE_FAILED (dispatched only when eg. a certain task fails)

For more in-depth information on the dispatched events, please see the [AccompliEvents][link-accompli-events-class] class.

Expand Down
Loading

0 comments on commit bac52c7

Please sign in to comment.