From d4c5ae2cf27ec295bbc7aea49888233b2178da6b Mon Sep 17 00:00:00 2001 From: vickytechkey Date: Tue, 8 Sep 2026 20:49:51 +0530 Subject: [PATCH] Fix deployment steps order to prevent permissions issue during composer install --- .forgejo/workflows/setup-ec2.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.forgejo/workflows/setup-ec2.yml b/.forgejo/workflows/setup-ec2.yml index be081b2b..ead0fb0b 100644 --- a/.forgejo/workflows/setup-ec2.yml +++ b/.forgejo/workflows/setup-ec2.yml @@ -65,21 +65,24 @@ jobs: cd /var/www/trypost && git pull origin main fi - # Install PHP dependencies and set permissions + # Ensure all storage subdirectories exist and have proper permissions BEFORE composer install cd /var/www/trypost - composer install --no-interaction --prefer-dist --optimize-autoloader - - # Ensure all storage subdirectories exist mkdir -p storage/logs storage/framework/views storage/framework/sessions storage/framework/cache bootstrap/cache - sudo chown -R www-data:www-data storage bootstrap/cache + sudo chown -R $USER:www-data storage bootstrap/cache sudo chmod -R 775 storage bootstrap/cache + # Install PHP dependencies + composer install --no-interaction --prefer-dist --optimize-autoloader + # Setup Laravel environment file and key if [ ! -f .env ]; then cp .env.example .env php artisan key:generate fi + # Ensure web server owns the files after composer finishes writing caches + sudo chown -R www-data:www-data storage bootstrap/cache + # Temporarily enable debug mode to see exactly why it is failing! sed -i 's/APP_DEBUG=false/APP_DEBUG=true/g' .env sed -i 's/APP_ENV=production/APP_ENV=local/g' .env