Skip to content

Commit

Permalink
Merge pull request #9 from studio24/add-check-deployer
Browse files Browse the repository at this point in the history
Add check for local deployer
  • Loading branch information
AlanJIsaacson authored Mar 31, 2021
2 parents f04130f + 976a057 commit c0bea12
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
1 change: 1 addition & 0 deletions all.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
require_once __DIR__ . '/src/display-disk-space.php';
require_once __DIR__ . '/src/vendors-subpath.php';
require_once __DIR__ . '/src/notify-slack.php';
require_once __DIR__ . '/src/check-local-deployer.php';
2 changes: 1 addition & 1 deletion docs/build-summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ No configuration is required.

## Tasks

- `studio24:build-summary` – retrieves current deployment info and creates a `_build_summary.json` file in the web root
- `s24:build-summary` – retrieves current deployment info and creates a `_build_summary.json` file in the web root

## Usage

Expand Down
36 changes: 36 additions & 0 deletions docs/check-local-deployer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Check local deployer recipe

Checks that deployment is running via the local Deployer install.
## Usage

Either [install all Studio 24 tasks](../README.md#installation) or install this individual task by adding to your `deploy.php`:

```php
require 'vendor/studio24/deployer-recipes/src/check-local-deployer.php';
```

## Configuration
The recipe detects the first item in the array of file paths only
````
$scriptPath = get_included_files()[0];
````

## Tasks

- `s24:check-local-deployer` – checks whether you are running local deployer, if not it stops the deployment

## Usage

Add task to the start of your `deploy.php` script:

```
task('deploy', [
...
// Add before deploy:info
's24:check-local-deployer',
// Run initial checks
'deploy:info',
...
]);
```
4 changes: 4 additions & 0 deletions examples/deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@

desc('Deploy ' . get('application'));
task('deploy', [

// Check that we are using local deployer
's24:check-local-deployer',

// Run initial checks
'deploy:info',
's24:check-branch',
Expand Down
13 changes: 13 additions & 0 deletions src/check-local-deployer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Deployer;

desc('Check currently used deployer path');
task('s24:check-local-deployer', function () {

$scriptPath = get_included_files()[0];

if (strpos($scriptPath, __DIR__.'/vendor/deployer/deployer/bin/dep') !== true) {
throw new \RuntimeException("Pleaae run using local Deployer with ./vendor/bin/dep");
}
});

0 comments on commit c0bea12

Please sign in to comment.