Skip to content

Commit

Permalink
VM
Browse files Browse the repository at this point in the history
  • Loading branch information
hangtantai committed Nov 27, 2024
1 parent 6b8d48b commit b2c9f83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ jobs:
run: |
docker save my-backend:latest -o my-backend.tar
- name: Create SSH key file
run: |
echo "${{ secrets.VM_SSH_KEY }}" > /tmp/vm_ssh_key.pem
chmod 600 /tmp/vm_ssh_key.pem
- name: Copy Docker image to VM
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.VM_HOST }}
username: ${{ secrets.VM_USERNAME }}
key: ${{ secrets.VM_SSH_KEY }}
script: |
echo "${{ secrets.VM_SSH_KEY }}" > /tmp/vm_ssh_key.pem
chmod 600 /tmp/vm_ssh_key.pem
scp -i /tmp/vm_ssh_key.pem -o StrictHostKeyChecking=no ./my-backend.tar ${{ secrets.VM_USERNAME }}@${{ secrets.VM_HOST }}:/home/${{ secrets.VM_USERNAME }}/my-backend.tar
rm /tmp/vm_ssh_key.pem
run: |
scp -i /tmp/vm_ssh_key.pem -o StrictHostKeyChecking=no my-backend.tar ${{ secrets.VM_USERNAME }}@${{ secrets.VM_HOST }}:/home/${{ secrets.VM_USERNAME }}/my-backend.tar
- name: Load Docker image and run container on VM
uses: appleboy/ssh-action@master
Expand All @@ -53,4 +50,8 @@ jobs:
fi
docker load -i /home/${{ secrets.VM_USERNAME }}/my-backend.tar &&
rm /home/${{ secrets.VM_USERNAME }}/my-backend.tar &&
docker run -d --name my-backend-container -p 80:80 my-backend:latest
docker run -d --name my-backend-container -p 80:80 my-backend:latest
- name: Clean up SSH key file
run: |
rm /tmp/vm_ssh_key.pem
1 change: 1 addition & 0 deletions hello-world.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
print("HH")
print("HH")
print("HH")
print("HH")
print("HH")

0 comments on commit b2c9f83

Please sign in to comment.