Turning several steps into one command.
WHAT A DEPLOYMENT SCRIPT DOES
Pulls the latest code Installs dependencies Runs database migrations Clears caches Sets permissions if needed Reports success or failure
WRITING ONE
A shell script in the repository, run over SSH. Keep it simple and readable.
Make it stop on the first error rather than continuing after a failure, or a failed dependency install is followed by a cache clear on broken code.
TESTING IT
Run it on staging repeatedly until it is reliable. A deployment script that works most of the time is worse than deploying by hand, because you stop watching.
LOGGING
Write output to a log file with a timestamp, so you can see what the last deployment did.
MAKING IT SAFE
Take a database backup as the first step Record the current commit so rollback is one command Verify the site responds at the end
TRIGGERING IT
Manually over SSH is fine. A webhook from your repository triggering it is the next step, once the script is proven.