Skip to content

Commit 3cd3c9e

Browse files
committed
fix: recreate build symlink on every deploy
store.aljebal-albeedos.com/build must symlink to modular-ecommerce-app/public/build because the web root and the Laravel app are in separate directories. Without the symlink, PHP generates URLs from the new manifest but Apache serves from the old static build in the web root, causing 404s for all assets. Set DEPLOY_WEBROOT=/home/aljedkrq/store.aljebal-albeedos.com in GitHub secrets.
1 parent 6353d89 commit 3cd3c9e

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,26 +116,19 @@ jobs:
116116
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
117117
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
118118
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
119-
DEPLOY_WEBROOT: ${{ secrets.DEPLOY_WEBROOT }}
120119
run: |
121120
rsync -az --delete -e "ssh -p $DEPLOY_PORT" \
122121
public/build/ \
123122
$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/public/build/
124123
125-
# If the domain's web root differs from DEPLOY_PATH/public, also
126-
# place assets there so the web server can serve them directly.
127-
if [ -n "$DEPLOY_WEBROOT" ]; then
128-
ssh -p $DEPLOY_PORT $DEPLOY_USER@$DEPLOY_HOST \
129-
"mkdir -p $DEPLOY_WEBROOT && ln -sfn $DEPLOY_PATH/public/build $DEPLOY_WEBROOT/build"
130-
fi
131-
132124
- name: Finalize deploy
133125
env:
134-
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
135-
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
136-
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
137-
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
138-
DEPLOY_PHP: ${{ secrets.DEPLOY_PHP }}
126+
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
127+
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
128+
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
129+
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
130+
DEPLOY_PHP: ${{ secrets.DEPLOY_PHP }}
131+
DEPLOY_WEBROOT: ${{ secrets.DEPLOY_WEBROOT }}
139132
RUN_MIGRATIONS: ${{ github.event.inputs.run_migrations || 'true' }}
140133
RUN_SCOUT_IMPORT: ${{ github.event.inputs.run_scout_import || 'false' }}
141134
run: |
@@ -144,6 +137,13 @@ jobs:
144137
PHP="${DEPLOY_PHP:-php}"
145138
cd $DEPLOY_PATH
146139
140+
# Ensure the web root's build/ points to the app's compiled assets.
141+
# The web root (DEPLOY_WEBROOT) differs from DEPLOY_PATH/public on this server.
142+
if [ -n "$DEPLOY_WEBROOT" ]; then
143+
ln -sfn $DEPLOY_PATH/public/build $DEPLOY_WEBROOT/build
144+
echo "==> Symlinked $DEPLOY_WEBROOT/build -> $DEPLOY_PATH/public/build"
145+
fi
146+
147147
echo "==> Caching configuration"
148148
\$PHP artisan config:cache
149149
\$PHP artisan route:cache

0 commit comments

Comments
 (0)