diff --git a/.forgejo/workflows/setup-ec2.yml b/.forgejo/workflows/setup-ec2.yml index 1c2ee95a..812868c6 100644 --- a/.forgejo/workflows/setup-ec2.yml +++ b/.forgejo/workflows/setup-ec2.yml @@ -54,10 +54,31 @@ jobs: sudo apt-get install -y nodejs fi - # 5. Create web directory and set basic permissions + # 5. Create web directory and deploy code sudo mkdir -p /var/www/trypost sudo chown -R $USER:$USER /var/www/trypost - + + # Clone or pull the latest code + if [ ! -d "/var/www/trypost/.git" ]; then + git clone http://16.113.106.152:3000/vignesh/trypost.git /var/www/trypost + else + cd /var/www/trypost && git pull origin main + fi + + # Install PHP dependencies and set permissions + cd /var/www/trypost + composer install --no-interaction --prefer-dist --optimize-autoloader + + # Ensure storage and bootstrap/cache directories exist and have proper permissions for Nginx/PHP-FPM + mkdir -p storage bootstrap/cache + sudo chown -R www-data:www-data storage bootstrap/cache + sudo chmod -R 775 storage bootstrap/cache + + # Setup Laravel environment file and key + if [ ! -f .env ]; then + cp .env.example .env + php artisan key:generate + fi # 6. Configure Nginx for socialmedia.tradhox.com echo "Configuring Nginx..." sudo tee /etc/nginx/sites-available/socialmedia.tradhox.com > /dev/null << 'EOF'