Skip to content

Commit 37faefb

Browse files
committed
fix: regenerate the staging web root's index.php/.htaccess/storage on every deploy
The staging web root is a standalone cPanel document root, not a symlink to $DEPLOY_PATH/public, so it needs its own Laravel bootstrap. Production has this hand-crafted once outside the deploy pipeline; codify the same thing for staging so a recreated web root self-heals: transform the app's own public/index.php (__DIR__.'/..' -> absolute $DEPLOY_PATH) instead of hardcoding file content in the workflow, plus copy .htaccess and symlink storage/app/public, matching production's exact structure (verified by diffing the two index.php files after normalization).
1 parent 4d1349d commit 37faefb

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

.github/workflows/deploy-staging.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,17 @@ jobs:
161161
PHP="${DEPLOY_PHP:-php}"
162162
cd $DEPLOY_PATH
163163
164-
# Ensure the web root's build/ points to the app's compiled assets.
164+
# The staging web root is a standalone directory (not a symlink to
165+
# $DEPLOY_PATH/public), so it needs its own bootstrap: compiled
166+
# assets, uploaded file storage, and an index.php/.htaccess pair
167+
# pointing at the real app. Regenerated every deploy so a
168+
# recreated web root self-heals instead of silently 404ing.
165169
if [ -n "$DEPLOY_WEBROOT" ]; then
166170
ln -sfn $DEPLOY_PATH/public/build $DEPLOY_WEBROOT/build
167-
echo "==> Symlinked $DEPLOY_WEBROOT/build -> $DEPLOY_PATH/public/build"
171+
ln -sfn $DEPLOY_PATH/storage/app/public $DEPLOY_WEBROOT/storage
172+
cp $DEPLOY_PATH/public/.htaccess $DEPLOY_WEBROOT/.htaccess
173+
sed "s#__DIR__\.'/\.\.#'$DEPLOY_PATH#g" $DEPLOY_PATH/public/index.php > $DEPLOY_WEBROOT/index.php
174+
echo "==> Regenerated web root bootstrap ($DEPLOY_WEBROOT)"
168175
fi
169176
170177
echo "==> Caching configuration"

0 commit comments

Comments
 (0)