Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

barbaz's avatar

Deploying from sub directory in Github via Forge

Does anyone know if it is possible to deploy from a subdirectory of a Github repository in Forge? For example Username/repo-name/tree/branch/subfolder ? Username/repo-name (the main repo) connects as intended, I just want to deploy from a directory if possible.

0 likes
1 reply
barbaz's avatar

Figured it out, maybe this will help someone in the future. Connect Forge to the main repo. And then put the following deploy script. Note rsync -a directory-you-want-to-deploy/ .

cd /home/forge/example.com
git pull origin $FORGE_SITE_BRANCH

rsync -a directory_you_want_to_deploy/ .

( flock -w 10 9 || exit 1
    echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock

if [ -f artisan ]; then
    $FORGE_PHP artisan migrate --force
fi
1 like

Please or to participate in this conversation.