Skip to content

Commit

Permalink
docgen
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Oct 13, 2024
1 parent 24012b9 commit 90154fe
Show file tree
Hide file tree
Showing 61 changed files with 1,396 additions and 61 deletions.
12 changes: 12 additions & 0 deletions docs/contrib/bugsnag.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ require 'contrib/bugsnag.php';



## Configuration
- *bugsnag_api_key* – the API Key associated with the project. Informs Bugsnag which project has been deployed. This is the only required field.
- *bugsnag_provider* – the name of your source control provider. Required when repository is supplied and only for on-premise services.
- *bugsnag_app_version* – the app version of the code you are currently deploying. Only set this if you tag your releases with semantic version numbers and deploy infrequently. (Optional.)
## Usage
Since you should only notify Bugsnag of a successful deployment, the `bugsnag:notify` task should be executed right at the end.
```php
after('deploy', 'bugsnag:notify');
```



## Tasks

### bugsnag:notify
Expand Down
68 changes: 67 additions & 1 deletion docs/contrib/cachetool.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,77 @@ require 'contrib/cachetool.php';
[Source](/contrib/cachetool.php)



## Configuration
- **cachetool** *(optional)*: accepts a *string* or an *array* of strings with the unix socket or ip address to php-fpm. If `cachetool` is not given, then the application will look for a configuration file. The file must be named .cachetool.yml or .cachetool.yaml. CacheTool will look for this file on the current directory and in any parent directory until it finds one. If the paths above fail it will try to load /etc/cachetool.yml or /etc/cachetool.yaml configuration file.
```php
set('cachetool', '/var/run/php-fpm.sock');
// or
set('cachetool', '127.0.0.1:9000');
// or
set('cachetool', ['/var/run/php-fpm.sock', '/var/run/php-fpm-other.sock']);
```
You can also specify different cachetool settings for each host:
```php
host('staging')
->set('cachetool', '127.0.0.1:9000');
host('production')
->set('cachetool', '/var/run/php-fpm.sock');
```
By default, if no `cachetool` parameter is provided, this recipe will fallback to the global setting.
If your deployment user does not have permission to access the php-fpm.sock, you can alternatively use
the web adapter that creates a temporary php file and makes a web request to it with a configuration like
```php
set('cachetool_args', '--web --web-path=./public --web-url=https://{{hostname}}');
```
## Usage
Since APCu and OPcache deal with compiling and caching files, they should be executed right after the symlink is created for the new release:
```php
after('deploy:symlink', 'cachetool:clear:opcache');
or
after('deploy:symlink', 'cachetool:clear:apcu');
```
## Read more
Read more information about cachetool on the website:
http://gordalina.github.io/cachetool/


## Configuration
### cachetool
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cachetool.php#L51)


## Configuration
- **cachetool** *(optional)*: accepts a *string* or an *array* of strings with the unix socket or ip address to php-fpm. If `cachetool` is not given, then the application will look for a configuration file. The file must be named .cachetool.yml or .cachetool.yaml. CacheTool will look for this file on the current directory and in any parent directory until it finds one. If the paths above fail it will try to load /etc/cachetool.yml or /etc/cachetool.yaml configuration file.
```php
set('cachetool', '/var/run/php-fpm.sock');
// or
set('cachetool', '127.0.0.1:9000');
// or
set('cachetool', ['/var/run/php-fpm.sock', '/var/run/php-fpm-other.sock']);
```
You can also specify different cachetool settings for each host:
```php
host('staging')
->set('cachetool', '127.0.0.1:9000');
host('production')
->set('cachetool', '/var/run/php-fpm.sock');
```
By default, if no `cachetool` parameter is provided, this recipe will fallback to the global setting.
If your deployment user does not have permission to access the php-fpm.sock, you can alternatively use
the web adapter that creates a temporary php file and makes a web request to it with a configuration like
```php
set('cachetool_args', '--web --web-path=./public --web-url=https://{{hostname}}');
```
## Usage
Since APCu and OPcache deal with compiling and caching files, they should be executed right after the symlink is created for the new release:
```php
after('deploy:symlink', 'cachetool:clear:opcache');
or
after('deploy:symlink', 'cachetool:clear:apcu');
```
## Read more
Read more information about cachetool on the website:
http://gordalina.github.io/cachetool/



Expand Down
71 changes: 71 additions & 0 deletions docs/contrib/chatwork.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,77 @@ require 'contrib/chatwork.php';
[Source](/contrib/chatwork.php)



# Chatwork Recipe
## Installing
1. Create chatwork account by any manual in the internet
2. Take chatwork token (Like: b29a700e2d15bef3f26ae6a5c142d1ea) and set `chatwork_token` parameter
3. Take chatwork room id from url after clicked on the room, and set `chatwork_room_id` parameter
4. If you want, you can edit `chatwork_notify_text`, `chatwork_success_text` or `chatwork_failure_text`
5. Require chatwork recipe in your `deploy.php` file
```php
# https://deployer.org/recipes.html
require 'recipe/chatwork.php';
```
Add hook on deploy:
```php
before('deploy', 'chatwork:notify');
```
## Configuration
- `chatwork_token` – chatwork bot token, **required**
- `chatwork_room_id` — chatwork room to push messages to **required**
- `chatwork_notify_text` – notification message template
```
[info]
[title](*) Deployment Status: Deploying[/title]
Repo: {{repository}}
Branch: {{branch}}
Server: {{hostname}}
Release Path: {{release_path}}
Current Path: {{current_path}}
[/info]
```
- `chatwork_success_text` – success template, default:
```
[info]
[title](*) Deployment Status: Successfully[/title]
Repo: {{repository}}
Branch: {{branch}}
Server: {{hostname}}
Release Path: {{release_path}}
Current Path: {{current_path}}
[/info]"
```
- `chatwork_failure_text` – failure template, default:
```
[info]
[title](*) Deployment Status: Failed[/title]
Repo: {{repository}}
Branch: {{branch}}
Server: {{hostname}}
Release Path: {{release_path}}
Current Path: {{current_path}}
[/info]"
```
## Tasks
- `chatwork:notify` – send message to chatwork
- `chatwork:notify:success` – send success message to chatwork
- `chatwork:notify:failure` – send failure message to chatwork
## Usage
If you want to notify only about beginning of deployment add this line only:
```php
before('deploy', 'chatwork:notify');
```
If you want to notify about successful end of deployment add this too:
```php
after('success', 'chatwork:notify:success');
```
If you want to notify about failed deployment add this too:
```php
after('deploy:failed', 'chatwork:notify:failure');
```


## Configuration
### chatwork_token
[Source](https://github.com/deployphp/deployer/blob/master/contrib/chatwork.php#L93)
Expand Down
43 changes: 43 additions & 0 deletions docs/contrib/cimonitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,49 @@ require 'contrib/cimonitor.php';
[Source](/contrib/cimonitor.php)



Monitor your deployments on [CIMonitor](https://github.com/CIMonitor/CIMonitor).
![CIMonitorGif](https://www.steefmin.xyz/deployer-example.gif)
Add tasks on deploy:
```php
before('deploy', 'cimonitor:notify');
after('deploy:success', 'cimonitor:notify:success');
after('deploy:failed', 'cimonitor:notify:failure');
```
## Configuration
- `cimonitor_webhook` – CIMonitor server webhook url, **required**
```
set('cimonitor_webhook', 'https://cimonitor.enrise.com/webhook/deployer');
```
- `cimonitor_title` – the title of application, default the username\reponame combination from `{{repository}}`
```
set('cimonitor_title', '');
```
- `cimonitor_user` – User object with name and email, default gets information from `git config`
```
set('cimonitor_user', function () {
return [
'name' => 'John Doe',
'email' => '[email protected]',
];
});
```
Various cimonitor statusses are set, in case you want to change these yourselves. See the [CIMonitor documentation](https://cimonitor.readthedocs.io/en/latest/) for the usages of different states.
## Usage
If you want to notify only about beginning of deployment add this line only:
```php
before('deploy', 'cimonitor:notify');
```
If you want to notify about successful end of deployment add this too:
```php
after('deploy:success', 'cimonitor:notify:success');
```
If you want to notify about failed deployment add this too:
```php
after('deploy:failed', 'cimonitor:notify:failure');
```


## Configuration
### cimonitor_title
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cimonitor.php#L64)
Expand Down
26 changes: 25 additions & 1 deletion docs/contrib/cloudflare.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,37 @@ require 'contrib/cloudflare.php';



### Configuration
- `cloudflare` – array with configuration for cloudflare
- `service_key` – Cloudflare Service Key. If this is not provided, use api_key and email.
- `api_key` – Cloudflare API key generated on the "My Account" page.
- `email` – Cloudflare Email address associated with your account.
- `api_token` – Cloudflare API Token generated on the "My Account" page.
- `domain` – The domain you want to clear (optional if zone_id is provided).
- `zone_id` – Cloudflare Zone ID (optional).
### Usage
Since the website should be built and some load is likely about to be applied to your server, this should be one of,
if not the, last tasks before cleanup



## Tasks

### deploy:cloudflare
[Source](https://github.com/deployphp/deployer/blob/master/contrib/cloudflare.php#L24)

Clears Cloudflare Cache.


### Configuration
- `cloudflare` – array with configuration for cloudflare
- `service_key` – Cloudflare Service Key. If this is not provided, use api_key and email.
- `api_key` – Cloudflare API key generated on the "My Account" page.
- `email` – Cloudflare Email address associated with your account.
- `api_token` – Cloudflare API Token generated on the "My Account" page.
- `domain` – The domain you want to clear (optional if zone_id is provided).
- `zone_id` – Cloudflare Zone ID (optional).
### Usage
Since the website should be built and some load is likely about to be applied to your server, this should be one of,
if not the, last tasks before cleanup


101 changes: 101 additions & 0 deletions docs/contrib/cpanel.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,107 @@ require 'contrib/cpanel.php';



### Description
This is a recipe that uses the [cPanel 2 API](https://documentation.cPanel.net/display/DD/Guide+to+cPanel+API+2).
Unfortunately the [UAPI](https://documentation.cPanel.net/display/DD/Guide+to+UAPI) that is recommended does not have support for creating addon domains.
The main idea behind is for staging purposes but I guess you can use it for other interesting concepts.
The idea is, every branch possibly has its own staging domain/subdomain (staging-neat-feature.project.com) and database db_neat-feature_project so it can be tested.
This recipe can make the domain/subdomain and database creation part of the deployment process so you don't have to manually create them through an interface.
### Configuration
The example uses a .env file and Dotenv for configuration, but you can set the parameters as you wish
```
set('cpanel', [
'host' => getenv('CPANEL_HOST'),
'port' => getenv('CPANEL_PORT'),
'username' => getenv('CPANEL_USERNAME'),
'auth_type' => getenv('CPANEL_AUTH_TYPE'),
'token' => getenv('CPANEL_TOKEN'),
'user' => getenv('CPANEL_USER'),
'db_user' => getenv('CPANEL_DB_USER'),
'db_user_privileges' => getenv('CPANEL_DB_PRIVILEGES'),
'timeout' => 500,
'allowInStage' => ['staging', 'beta', 'alpha'],
'create_domain_format' => '%s-%s-%s',
'create_domain_values' => ['staging', 'master', get('application')],
'subdomain_prefix' => substr(md5(get('application')), 0,4) . '-',
'subdomain_suffix' => getenv('SUDOMAIN_SUFFIX'),
'create_db_format' => '%s_%s-%s-%s',
'create_db_values' => ['apps', 'staging','master', get('application')],
]);
```
- `cpanel` – array with configuration for cPanel
- `username` – WHM account
- `user` – cPanel account that you want in charge of the domain
- `token` – WHM API token
- `create_domain_format` – Format for name creation of domain
- `create_domain_values` – The actual value reference for naming
- `subdomain_prefix` – cPanel has a weird way of dealing with addons and subdomains, you cannot create 2 addons with the same subdomain, so you need to change it in some way, example uses first 4 chars of md5(app_name)
- `subdomain_suffix` – cPanel has a weird way of dealing with addons and subdomains, so the suffix needs to be your main domain for that account for deletion purposes
- `addondir` – addon dir is different from the deploy path because cPanel "injects" /home/user/ into the path, so tilde cannot be used
- `allowInStage` – Define the stages that cPanel recipe actions are allowed in
#### .env file example
```
CPANEL_HOST=xxx.xxx.xxx.xxx
CPANEL_PORT=2087
CPANEL_USERNAME=root
CPANEL_TOKEN=xxxx
CPANEL_USER=xxx
CPANEL_AUTH_TYPE=hash
CPANEL_DB_USER=db_user
CPANEL_DB_PRIVILEGES="ALL PRIVILEGES"
SUDOMAIN_SUFFIX=.mymaindomain.com
```
### Tasks
- `cpanel:createaddondomain` Creates an addon domain
- `cpanel:deleteaddondomain` Removes an addon domain
- `cpanel:createdb` Creates a new database
### Usage
A complete example with configs, staging and deployment
```
<?php
namespace Deployer;
use Dotenv\Dotenv;
require 'vendor/autoload.php';
(Dotenv::create(__DIR__))->load(); // this is used just so an .env file can be used for credentials
require 'cpanel.php';
Project name
set('application', 'myproject.com');
Project repository
set('repository', '[email protected]:myorg/myproject.com');
set('cpanel', [
'host' => getenv('CPANEL_HOST'),
'port' => getenv('CPANEL_PORT'),
'username' => getenv('CPANEL_USERNAME'),
'auth_type' => getenv('CPANEL_AUTH_TYPE'),
'token' => getenv('CPANEL_TOKEN'),
'user' => getenv('CPANEL_USER'),
'db_user' => getenv('CPANEL_DB_USER'),
'db_user_privileges' => getenv('CPANEL_DB_PRIVILEGES'),
'timeout' => 500,
'allowInStage' => ['staging', 'beta', 'alpha'],
'create_domain_format' => '%s-%s-%s',
'create_domain_values' => ['staging', 'master', get('application')],
'subdomain_prefix' => substr(md5(get('application')), 0,4) . '-',
'subdomain_suffix' => getenv('SUDOMAIN_SUFFIX'),
'create_db_format' => '%s_%s-%s-%s',
'create_db_values' => ['apps', 'staging','master', get('application')],
]);
host('myproject.com')
->stage('staging')
->set('cpanel_createdb', vsprintf(get('cpanel')['create_db_format'], get('cpanel')['create_db_values']))
->set('branch', 'dev-branch')
->set('deploy_path', '~/staging/' . vsprintf(get('cpanel')['create_domain_format'], get('cpanel')['create_domain_values']))
->set('addondir', 'staging/' . vsprintf(get('cpanel')['create_domain_format'], get('cpanel')['create_domain_values']));
Tasks
task('build', function () {
run('cd {{release_path}} && build');
});
after('deploy:prepare', 'cpanel:createaddondomain');
after('deploy:prepare', 'cpanel:createdb');
```



## Tasks

### cpanel:createdb
Expand Down
Loading

0 comments on commit 90154fe

Please sign in to comment.