From bb8fcba8a3b8cae3d1bb721a1cecac5cefe22354 Mon Sep 17 00:00:00 2001 From: vickytechkey Date: Tue, 20 Oct 2026 20:48:44 +0530 Subject: [PATCH] fix(ci): optimize ec2 deploy script, remove slow apt-get upgrade and increase timeout --- .forgejo/workflows/setup-ec2.yml | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/.forgejo/workflows/setup-ec2.yml b/.forgejo/workflows/setup-ec2.yml index 6f4f1ff6..a78439f9 100644 --- a/.forgejo/workflows/setup-ec2.yml +++ b/.forgejo/workflows/setup-ec2.yml @@ -19,22 +19,28 @@ jobs: host: ${{ secrets.BETA_EC2_HOST }} username: ${{ secrets.BETA_EC2_USERNAME }} key: ${{ secrets.BETA_EC2_SSH_KEY }} + command_timeout: 30m script: | echo "Starting EC2 Server Setup..." + export DEBIAN_FRONTEND=noninteractive - # 1. Update package list + # 1. Update package list and install prerequisites if missing sudo apt-get update -y - sudo apt-get upgrade -y - sudo apt-get install -y software-properties-common curl git unzip nginx supervisor redis-server + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends software-properties-common curl git unzip nginx supervisor redis-server # 2. Add PHP repository and install PHP 8.4 with required extensions - sudo add-apt-repository -y ppa:ondrej/php - sudo apt-get update -y - sudo apt-get install -y php8.4-fpm php8.4-cli php8.4-pgsql php8.4-mbstring php8.4-xml php8.4-curl php8.4-zip php8.4-bcmath php8.4-intl php8.4-redis php8.4-gd + if ! command -v php8.4 &> /dev/null; then + sudo add-apt-repository -y ppa:ondrej/php + sudo apt-get update -y + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php8.4-fpm php8.4-cli php8.4-pgsql php8.4-mbstring php8.4-xml php8.4-curl php8.4-zip php8.4-bcmath php8.4-intl php8.4-redis php8.4-gd + fi - # 3. Install Node.js (required for Vite frontend assets) - curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - - sudo apt-get install -y nodejs + # 3. Install Node.js (Node 22) if missing + if ! command -v node &> /dev/null; then + echo "Installing Node.js 22..." + curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs + fi # 4. Install Composer (PHP Package Manager) if ! command -v composer &> /dev/null; then @@ -51,13 +57,6 @@ jobs: rm composer-setup.php fi - # 4. Install Node.js (v20) and NPM for building frontend assets - if ! command -v node &> /dev/null; then - echo "Installing Node.js..." - curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - - sudo apt-get install -y nodejs - fi - # 5. Create web directory and deploy code sudo mkdir -p /var/www/trypost sudo chown -R $USER:$USER /var/www/trypost