Skip to content

Commit 5cfb4f1

Browse files
committed
Added forge config example
README.md Removed unused method from Exec service Bug fix and updates Deployment successful now fires even if success closure not defined Updated config publish name to atm-config
1 parent 59dd574 commit 5cfb4f1

File tree

4 files changed

+52
-19
lines changed

4 files changed

+52
-19
lines changed

README.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ composer require jtmcc/atomic-deployments
1616

1717
php artisan migrate
1818

19-
php artisan vendor:publish --tag=config
19+
php artisan vendor:publish --tag=atm-config
2020

2121
```
2222

@@ -142,6 +142,53 @@ php artisan atomic-deployments:list
142142
- DeploymentSuccessful
143143
- DeploymentFailed
144144

145+
## Laravel Forge Example
146+
147+
Here is a basic configuration for use with Forge
148+
149+
#### *Deploy Script*
150+
151+
```shell script
152+
cd /home/forge/your-application.com
153+
git pull origin main
154+
$FORGE_COMPOSER install --no-interaction --prefer-dist --optimize-autoloader
155+
156+
( flock -w 10 9 || exit 1
157+
echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock
158+
159+
if [ -f artisan ]; then
160+
$FORGE_PHP artisan migrate --force
161+
$FORGE_PHP artisan optimize:clear
162+
$FORGE_PHP artisan atomic-deployments:deploy
163+
fi
164+
```
165+
166+
#### *.env*
167+
168+
Build project .env
169+
170+
```dotenv
171+
ATM_DEPLOYMENT_LINK="/home/forge/your-application.com-link"
172+
ATM_BUILD="/home/forge/your-application.com"
173+
ATM_DEPLOYMENTS="/home/forge/deployments/your-application.com"
174+
```
175+
176+
#### *nginx config*
177+
178+
```shell script
179+
root /home/forge/your-application.com-link/public;
180+
```
181+
182+
#### *schedule command*
183+
184+
```shell script
185+
php8.0 /home/forge/your-application.com-link/artisan schedule:run
186+
```
187+
188+
If your application is isolated, you must ensure that your deployments folder has the appropriate permissions to serve
189+
your application for that user.
190+
191+
145192
## License
146193

147194
MIT

src/AtomicDeploymentsServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ protected function registerPublishables(): void
2626
{
2727
$this->publishes([
2828
__DIR__ . '/../config/atomic-deployments.php' => config_path('atomic-deployments.php'),
29-
], 'config');
29+
], 'atm-config');
3030

3131
$this->publishes([
3232
__DIR__.'/../database/migrations/' =>database_path('migrations'),
33-
], 'migrations');
33+
], 'atm-migrations');
3434
}
3535

3636
protected function registerCommands(): void

src/Services/AtomicDeployments.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ public function deploy(?Closure $success = null, ?Closure $failed = null): void
9494
$this->confirmSymbolicLink($this->deploymentPath);
9595
$this->updateDeploymentStatus(DeploymentStatus::SUCCESS);
9696

97+
DeploymentSuccessful::dispatch($this, $this->model);
98+
9799
if ($success) {
98-
DeploymentSuccessful::dispatch($this, $this->model);
99100
$success($this);
100101
}
101102

src/Services/Exec.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,6 @@ public static function rsync(string $from, string $to) {
7878
}
7979

8080

81-
/**
82-
* @param string $from
83-
* @param string $to
84-
* @param string $pattern
85-
*
86-
* @return string
87-
*
88-
* @throws ExecuteFailedException
89-
*/
90-
public static function rsyncPattern(string $from, string $to, string $pattern) {
91-
$from = rtrim($from, DIRECTORY_SEPARATOR ) . '/';
92-
$to = rtrim($to, DIRECTORY_SEPARATOR) . '/';
93-
return self::run('rsync -aW --no-compress --include="'.$pattern.'" --exclude="*" %s %s', [$from, $to]);
94-
}
95-
9681

9782
/**
9883
* @return string

0 commit comments

Comments
 (0)