Merge pull request #50 from danial117/client_dev_34 #75
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SSH Client CICD | |
on: | |
push: | |
branches: | |
- client | |
jobs: | |
ssh-folder-management: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up SSH client | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y sshpass | |
- name: Connect to SSH and perform operations | |
env: | |
SERVER_IP: ${{ secrets.SERVER_IP }} | |
SERVER_USER: ${{ secrets.SERVER_USER }} | |
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/htdocs/www.infovit.us || exit | |
# Delete all files and directories except 'public' | |
find . -mindepth 1 -maxdepth 1 ! -name 'public' -exec rm -rf {} + | |
# Remove all contents inside 'public' directory | |
find public -mindepth 1 -exec rm -rf {} + | |
# Clone the specific branch of the GitHub repository into a temporary directory | |
git clone -b client https://github.com/danial117/Pharma.git ./git | |
# Navigate to the temporary repository directory | |
cd ./git || exit | |
# Install dependencies and build the project | |
npm install | |
npm run build | |
# Move build files to the target directory | |
mv build/* ../ | |
# Clean up by removing the temporary directory | |
cd .. | |
rm -rf ./git | |
EOF | |