Skip to content

Commit 43a21e0

Browse files
authored
Update main.yml
1 parent 3c6a8d5 commit 43a21e0

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ jobs:
1313
- name: Checkout Repository
1414
uses: actions/checkout@v3
1515

16-
- name: Set up SSH with Password Authentication
17-
run: |
18-
echo "$PASSWORD" | sudo -S echo "Password authentication is set up" # Use PASSWORD secret for sudo
19-
env:
20-
PASSWORD: ${{ secrets.PASSWORD }}
16+
- name: Install sshpass
17+
run: sudo apt-get install -y sshpass
2118

2219
- name: Add Azure VM to known_hosts
2320
run: |
@@ -28,18 +25,18 @@ jobs:
2825
run: |
2926
cat ~/.ssh/known_hosts # Optional step to confirm the host is added
3027
31-
- name: Synchronize Code with Azure VM Using rsync
28+
- name: Synchronize Code with Azure VM Using rsync and sshpass
3229
env:
33-
RSYNC_RSH: "ssh"
30+
PASSWORD: ${{ secrets.PASSWORD }}
3431
run: |
35-
rsync -avz --exclude='.git' --exclude='.env' -e "ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no" ./ ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }}:/home/devops/CAPEC-Rag/
32+
sshpass -p "$PASSWORD" rsync -avz --exclude='.git' --exclude='.env' -e "ssh -o StrictHostKeyChecking=no" ./ ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }}:/home/devops/CAPEC-Rag/
3633
3734
- name: Restart Docker Compose Services
3835
uses: appleboy/[email protected]
3936
with:
4037
host: ${{ secrets.VM_HOST }}
4138
username: ${{ secrets.VM_USER }}
42-
password: ${{ secrets.PASSWORD }} # Using the PASSWORD secret for SSH login
39+
password: ${{ secrets.PASSWORD }}
4340
script: |
4441
echo "Stopping existing Docker Compose services..."
4542
cd /home/devops/CAPEC-Rag/

0 commit comments

Comments
 (0)