I am trying to setup a cronjob for automatic deployment of Laravel app with Vite.
The goal is pretty simple: when a commit made to a main branch, github sends webhook to aaPanel and sequent commands are being executed:
1. cd /www/wwwroot/mylaravelapp.com
2. git pull
3. php artisan down
4. npm install
5. npm run build
6. composer install
7. php artisan migrate --force
8. php artisan view:clear
9. php artisan config:cache
10. php artisan route:cache
11. php artisan view:cache
12. php artisan event:cache
13. php artisan queue:restart
14. php artisan up
But this execution fails on this steps:
2. git pull
fatal: detected dubious ownership in repository at '/www/wwwroot/mylaravelapp.com'
To add an exception for this directory, call:
git config --global --add safe.directory /www/wwwroot/mylaravelapp.com
executing this command didnt help
6. composer install
Composer plugins have been disabled for safety in this non-interactive session.
Set COMPOSER_ALLOW_SUPERUSER=1 if you want to allow plugins to run as root/super user.
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Plugins have been disabled automatically as you are running as root, this may be the cause of the following exception. See also https://getcomposer.org/root
after npm build process built static files owned by root, but this is not great problem we can manually set correct privilegies.
The question is how to handle 2 and 6 step. If you can help, we can make a very usefull tutorial for laravel developers. Thanks! Waiting for the answer!