Skip to content

Feature Preview Branches with Laravel Harbor

For the past few weeks I’ve been experimenting with a solution called Laravel Harbor, which is an open source Laravel app that you can use with GitHub Actions to deploy new environments to a Laravel Forge.

This allows me to quickly spin up an environment containing a single new feature or bug fix for QA and UAT automatically when a pull request is created containing [preview] in the pull request title. By default it will use your Git branch name. For example, if your branch was fix-8943 and you configured Harbor to make each environment a subdomain of exmaple.com, it would be:

fix-8943.example.com

Doing this gets the isolated feature/fix to our QA team earlier, allows code review, QA and UAT to happen much faster than when we were merging branches into a qa or develop branch where the code would often get blocked by another change in that branch.

The author of the Laravel Harbor package, Mehran Rasulian, is a Laravel developer in Turkey. He’s been extremely responsive to bug reports and great to work with when I decided to contribute a few changes to the package.

Harbor is still in beta. But currently, it will:

  • Create the Site
  • Create the Database
  • Set Environment Variables
  • Enable LetsEncrypt SSL
  • Run any post-deployment commands you need
  • Add a Comment to the Pull Request announcing the new preview environment is live.
  • Send a message to a specific Slack channel announcing the new preview environment is live.

What it won’t do yet: Because Horizon uses the Laravel Forge SDK, and that SDK does not have support for these features, you can’t:

  • Enable Horizon
  • Enable Inertia SSR

You’d have to manually enable these in the Forge dashboard.

I’ve also successfully used Harbor to run my Laravel Dusk tests against a preview environment, and store all the output (logs & screenshots) as assets in the GitHub PR.

Check it out!

2 Comments

  1. @shooper Oh nice! Not using forge, but I've been doing something similar for years with a custom build/deploy server, doing it on all pushes to all branches instead of only on PR's, so great to be able to test everything easily through <branch>.dev.domain.tld 🙂

    • Shawn Hooper Shawn Hooper

      It’s so nice to be able to flip something that’s WIP to a colleague who doesn’t have a local environment.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.