Published 1 month ago by Aaranihlus
I am new to using GitHub and I would like to ask a question on how to use it properly.
I have a server which I currently have a web app on.
I have a GitHub repository with my laravel project in it.
I downloaded my laravel project files from GitHub onto my server using git clone in the ssh terminal.
Now, I want to do some additional work on this project and push those changes to the live server, what is the recommended way of doing this?
Will I have to run npm run production to recompile all of my assets again? Will i have to reinstall all composer dependencies again?
I'm new to this and I'd really appreciate the help with all of the general workings of Git.
Thanks for reading Nathan
Not necessarily install, more like reinstall.
So basically, the workflow is:
Regarding step 2, this can also include an upgrade to a new laravel version or just general update. So maybe the only thing you do is a 'composer update ' which, for git, will only change one single file: composer.lock.
But, based on that file, your live server will install the correct packages in step 6. Take care not to run 'composer update' on live (always do 'composer install'), as the update will search for any new version and creating its own composer.lock file in the process. Hello merge conflict!
One of two methods. The best and least headache (once setup) is using some sort of CI/CD system. Personally I use Gitlab for everything (self hosted).
The other option is to create a bash script on the production server that does all the magic for you (git pull, npm run production, copy environment files, do route caching and whatever else you need).
Which choice I go with depends upon client/project needs. Something that won't be updated all that often, I just do the simple bash script. For more complex projects with frequent updates then CI/CD is the way to go and saves tons of headaches in the long run.