Kodfolk · We don't have anything to sell. Just want to say hi!
Ryan Chandler Ryan Chandler

Quickly deploy your Forge site from the terminal

Tips & Tricks

Forge is the way that I deploy most of my projects but I've never been a big user of the official CLI.

I instead use a Bash script to deploy my sites from the terminal. I figured it could be useful for somebody else so here's my script.

#!/usr/bin/env bash

echo "Deploying..."

# You can get this from the "Deployments" page in your site settings.
FORGE_DEPLOY_URL="https://forge.laravel.com/servers/<SERVER_ID>/sites/<SITE_ID>/deploy/http?token=<TOKEN>"
FORGE_DEPLOY_COMMIT=$(git rev-parse HEAD)
FORGE_DEPLOY_MESSAGE=$(git log -1 --pretty=%B | xargs)
FORGE_DEPLOY_AUTHOR="Ryan Chandler"

curl -X POST $FORGE_DEPLOY_URL \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -d "forge_deploy_commit=${FORGE_DEPLOY_COMMIT}&forge_deploy_author=${FORGE_DEPLOY_AUTHOR}&forge_deploy_message=${FORGE_DEPLOY_MESSAGE}"

echo "Deployment request submitted."

The nice part is that you can still specify the Git details for the deployment!