Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

autefrum's avatar

automating git testing and migrations - what is best practice in a Laravel context?

As a Test environment for my cloud app, I have an AWS Elastic Beanstalk EC2 machhine on a distinct URL to my live site. I connect via SSH to a terminal and use git pull to update the test environment code to the the current 'next' git branch version.

I am not using git hub, I am using a proprietary git repository that is part of out ticket management system.

I prefer to manually initiate a pull by on the test environment server console as it gives me control and confidence that it is happening only when I want it to happen.

Question 1: Should I be pushing , or is a manual pull sensible?

Database migrations:

I included php artisan migrate in the post-merge file (post merge hook is called after a pull that makes changes, as a pull performs a merge if there are changes):

file cd /var/www/html/tsheets/<my_app_folder>/.git/hooks/post-merge

#!/bin/sh
php artisan migrate

This seems to work well, and I no longer have to remember to run the migrations when I deploy new code.

Question 2: Is this 'OK' or is there a risk I am not aware of?

Testing:

I plan to also run the test cases in the pre-commit client side hook. This aims to ensure that the version of the app running on the developer's machine "works".

Queston 3: Is this a sensible way to minimise the risk that developers commit broken code, or is there a different hook I am unaware of?

My team is not large enough to need to use pull requests yet, but if i wanted to do that, am I correct in saying git (not github) has not permissions, and relies on the file system security - the user running the git command needs to have permission to modify the folder containing the code?

Question 4 - npm run production? npm install?

My development machines have a multitude of configs, but the test machine is the same (or as close as you get to the same) as the production site.

Should this be where I run npm install and/or npm run production?

Should I do this from the hook scripts?

0 likes
0 replies

Please or to participate in this conversation.