Skip to content

Commit

Permalink
Update main.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
danial117 committed Aug 21, 2024
1 parent b7ff13c commit 09daaae
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 09daaae

Please sign in to comment.