Speed up deployments

Faster deployments in code pipelines

Patrick Riemer

When you are deploying a Laravel application with Laravel Forge, Ploi, AWS Code Build or similar the installation of composer and node dependencies can take a long time. Many time they even didn’t change. You can use a simple bash script to check if the composer or package lock files have changed and only run composer install or npm install when there was any change.

                    
                        current_commit=$(git rev-parse HEAD)

                        git pull origin release

                        if git diff --name-only $current_commit..HEAD | grep 'composer.lock'
                        then
                            composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
                        fi

                        if git diff --name-only $current_commit..HEAD | grep 'package.lock'
                        then
                            npm install
                        fi

                        npm run build