How can I add a series of commands to Forge's Quick Deploy I have to run these commands after every deployment or else I lose all of my symbolic links in production.
cd public
rm avatars
rm forms
rm media
rm occms
rm tickets
cd ..
php artisan storage:link
This is the current deploy script
cd /home/forge/www.my-uam.com
git stash
git pull origin master
$FORGE_COMPOSER install --no-interaction --prefer-dist --optimize-autoloader
( flock -w 10 9 || exit 1
echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock
if [ -f artisan ]; then
$FORGE_PHP artisan migrate --force
fi
You can use a composer hook for this
post-install-cmd
Create a new Laravel Command that does all of what you need it to do.
Then in your composer.json
add this to your scripts
"scripts": {
"pre-install-cmd": [
"@php artisan your:command "
],
}
This will run the command anytime composer installs.
A second option would be to handle the command in the deploy script
cd /home/forge/www.my-uam.com
git stash
git pull origin master
$FORGE_COMPOSER install --no-interaction --prefer-dist --optimize-autoloader
( flock -w 10 9 || exit 1
echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock
if [ -f artisan ]; then
$FORGE_PHP artisan migrate --force
$FORGE_PHP artisan your:command
fi
I’ve used Laravel Forge for quite a while in my workflow. It’s a convenient way to set up servers, quickly add security certificates, and deploy sites. I’ve got a number of my own sites and client sites using it and I’ve been very pleased with it.
https://www.indigocard.one/
This is the start of my command (never written one like THIS before):
public function handle(): int
{
exec("cd public");
exec("pwd", $output);
$this->comment( implode( PHP_EOL, $output ) );
return 0;
} // end function
The output is /Users/jongravois/code/eight which is the root of the app. It appears as though it ignored the ``change directory``` command.
public function handle(): int
{
collect(['avatars', 'forms', 'media', 'occms', 'tickest'])
->each(function ($item) {
File::delete(public_path($item));
});
$this->call('storage:link');
return 0;
}
Please sign in or create an account to participate in this conversation.