From 09daaaecdb0e7be33625ecad61abe330415ad377 Mon Sep 17 00:00:00 2001 From: danial117 <149282370+danial117@users.noreply.github.com> Date: Wed, 21 Aug 2024 11:14:48 +0500 Subject: [PATCH] Update main.yml --- .github/workflows/main.yml | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6ec042d..687d278 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,25 +27,35 @@ jobs: SERVER_PASSWORD: ${{ secrets.SERVER_PASSWORD }} run: | sshpass -p "$SERVER_PASSWORD" ssh -o StrictHostKeyChecking=no "$SERVER_USER@$SERVER_IP" << 'EOF' - # Navigate to the target directory - cd /home/infovit-api/htdocs + # Navigate to the target directory + cd /home/infovit-api/htdocs/api.infovit.us - # Find and delete all files and directories within api.infovit.us except for ecosystem.config.js - find api.infovit.us -mindepth 1 ! -name 'ecosystem.config.cjs' -exec rm -rf {} + + # Delete all files and directories except 'ecosystem.config.cjs' and 'public' + find . -mindepth 1 -maxdepth 1 ! -name 'ecosystem.config.cjs' ! -name 'public' ! -name '.env' -exec rm -rf {} + - # If you need to ensure the directory is empty, but leave ecosystem.config.js - cd /home/infovit-api/htdocs/api.infovit.us - + - # Clone the specific branch of the GitHub repository into the Pharma directory - git clone -b server https://github.com/danial117/Pharma.git /home/infovit-api/htdocs/api.infovit.us + # Clone the specific branch of the GitHub repository into a temporary directory + git clone -b server https://github.com/danial117/Pharma.git ./git - # Change to the directory and install dependencies - cd /home/infovit-api/htdocs/api.infovit.us + # Move the contents of the temporary directory to the target directory + mv ./git/* ./ + mv ./git/.[!.]* ./ # Move hidden files + + # Clean up by removing the temporary directory + rm -rf ./git + rm -rf ./.git + rm -rf ./.github + + # Install dependencies npm install # Start the application with pm2 + pm2 delete all + pm2 start ecosystem.config.cjs --env production + + # Create the 'public' directory with 'brands', 'products', and 'news' subdirectories mkdir -p /home/infovit-api/htdocs/api.infovit.us/public/brands @@ -54,4 +64,5 @@ jobs: mkdir -p /home/infovit-api/htdocs/api.infovit.us/public/products/medium mkdir -p /home/infovit-api/htdocs/api.infovit.us/public/products/small mkdir -p /home/infovit-api/htdocs/api.infovit.us/public/news + EOF