-
-
Notifications
You must be signed in to change notification settings - Fork 0
38 lines (30 loc) · 1.52 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Send Code to VM
on:
push:
branches:
- main
jobs:
send-code:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup SSH
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} # Sets up the SSH private key
- name: Create SSH Private Key File
run: |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > private_key.pem # Creates a new file named private_key.pem and writes the private key to it
chmod 600 private_key.pem # Changes the permission of the private key file to read and write only by the owner
- name: Check if App folder exists and delete if it does
run: |
ssh -o StrictHostKeyChecking=no -i private_key.pem ${{ secrets.USERNAME }}@${{ secrets.VM_IP }} '[ -d ~/App ] && rm -rf ~/App || true' # Deletes the App directory if it exists
ssh -o StrictHostKeyChecking=no -i private_key.pem ${{ secrets.USERNAME }}@${{ secrets.VM_IP }} 'mkdir App' # Creates a new directory named App in the home directory of the user on VM
- name: Copy code to VM
run: |
ls -a # Lists all files and directories in the current directory
scp -o StrictHostKeyChecking=no -i private_key.pem -r ${{ secrets.USERNAME }}@${{ secrets.VM_IP }}:~/App # Copies all files and directories to the home directory of the user on VM
- name: Clean Up
run: |
rm private_key.pem # Deletes the private key file