Skip to content

Commit 1d7b1b7

Browse files
committed
fix: reorder deploy steps so assets upload before artisan cache
- Split into 3 steps: pull+composer | rsync assets | artisan cache+migrate - Use rsync --delete instead of scp so old hashed files are removed - artisan view:cache now runs after assets exist, baking correct hashes - Final step logs asset count to confirm upload succeeded
1 parent e74dfdf commit 1d7b1b7

1 file changed

Lines changed: 26 additions & 10 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,39 @@ jobs:
8484
- name: Add server to known hosts
8585
run: ssh-keyscan -p ${{ secrets.DEPLOY_PORT }} -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts
8686

87+
- name: Pull latest code & install PHP dependencies
88+
env:
89+
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
90+
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
91+
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
92+
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
93+
DEPLOY_PHP: ${{ secrets.DEPLOY_PHP }}
94+
run: |
95+
ssh -p $DEPLOY_PORT $DEPLOY_USER@$DEPLOY_HOST << EOF
96+
set -e
97+
PHP="${DEPLOY_PHP:-php}"
98+
cd $DEPLOY_PATH
99+
100+
echo "==> Pulling latest code"
101+
git pull origin main
102+
103+
echo "==> Installing PHP dependencies"
104+
COMPOSER=\$(which composer 2>/dev/null || echo "\$HOME/bin/composer")
105+
\$PHP \$COMPOSER install --no-dev --no-interaction --optimize-autoloader --prefer-dist
106+
EOF
107+
87108
- name: Upload built assets
88109
env:
89110
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
90111
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
91112
DEPLOY_USER: ${{ secrets.DEPLOY_USER }}
92113
DEPLOY_PATH: ${{ secrets.DEPLOY_PATH }}
93114
run: |
94-
scp -P $DEPLOY_PORT -r public/build $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/public/
115+
rsync -az --delete -e "ssh -p $DEPLOY_PORT" \
116+
public/build/ \
117+
$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH/public/build/
95118
96-
- name: Deploy
119+
- name: Finalize deploy
97120
env:
98121
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
99122
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT }}
@@ -108,13 +131,6 @@ jobs:
108131
PHP="${DEPLOY_PHP:-php}"
109132
cd $DEPLOY_PATH
110133
111-
echo "==> Pulling latest code"
112-
git pull origin main
113-
114-
echo "==> Installing PHP dependencies"
115-
COMPOSER=\$(which composer 2>/dev/null || echo "\$HOME/bin/composer")
116-
\$PHP \$COMPOSER install --no-dev --no-interaction --optimize-autoloader --prefer-dist
117-
118134
echo "==> Caching configuration"
119135
\$PHP artisan config:cache
120136
\$PHP artisan route:cache
@@ -139,7 +155,7 @@ jobs:
139155
\$PHP artisan scout:import "App\Domain\Order\Models\Order"
140156
fi
141157
142-
echo "==> Done"
158+
echo "==> Done (\$(ls $DEPLOY_PATH/public/build/assets/ | wc -l) assets)"
143159
EOF
144160
145161
- name: Notify on failure

0 commit comments

Comments
 (0)