Urgent.News

What's breaking now, across thousands of outlets.

Tech

How I Automated My Laravel Deployments to a VPS with GitHub Actions and SSH

Running a Laravel application on a VPS usually means repeating the same routine: connecting via SSH, pulling latest changes, running composer updates, migrating the database, and clearing caches manually. It works, but it's repetitive and prone to human error. So I automated the boring part. In this guide, I'll walk through setting up a lightweight Continuous Deployment (CD) pipeline using:…

Automating Laravel deployments on a VPS can be simplified using GitHub Actions and SSH key authentication. This guide outlines the process of setting up a lightweight Continuous Deployment pipeline for Laravel applications on a Linux VPS (Ubuntu) hosted on GitHub. The core flow involves pushing code changes that trigger GitHub Actions to connect to the VPS via SSH and execute deployment commands.

The process begins by ensuring the local project is linked to the GitHub repository and verifying the server folder structure. Next, Git's ownership issue is addressed to allow safe execution of Git commands. GitHub secrets are then configured to securely store SSH authentication details. A GitHub Actions workflow file (.github/workflows/deploy.yml) is created to define the deployment steps.

The deployment workflow includes steps such as setting up the SSH connection, putting the application into maintenance mode, pulling the latest changes from the main branch, installing production dependencies, running database migrations, clearing caches, and finally bringing the app back online. The deployment commands are executed over SSH, ensuring a secure and automated deployment process.

By following these steps, developers can achieve an efficient and error-resistant deployment process for their Laravel applications hosted on a VPS, enhancing productivity while minimizing the risk of manual errors.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Wednesday 23 September →