Forge: Deploy Script Environment Variables

Jun, 16 2020#forge

We've super-charged custom deployment scripts in Laravel Forge with the addition of dynamic environment variables.

When Forge deploys your website, we will now automatically inject several environment variables within the context of your deployment. You can use these to further customize your deployments.

These variables can be used to control your deployments in ways that were not previously possible. For example, you could stop deployments if the commit message contains "wip" and if it didn't come from a manual deployment:

if [[ $FORGE_DEPLOY_MESSAGE =~ "wip" ]]; then
    if [[ $FORGE_MANUAL_DEPLOY -eq 0 ]]; then
        echo "WIP commits will not deploy automatically..."
        exit 1
    fi
fi

All environment variables will be unloaded after a deployment and are not accessible when fetching the deploy script via the Forge API.

You can learn more at the Forge documentation.

By James Brooks

Software Developer at Laravel, working on Forge and Envoyer.

Find me on Twitter, GitHub or my blog.

Follow the RSS Feed.