Merge pull request #165 from AnkanSaha/dev #17
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: 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 |