Mohamed Ramadan
Mohamed Ramadan

Reputation: 3

Closing all processes in Windows using SSH from GitHub using taskkill command

I am having GitHub workflow to connect to windows using SSH, this connection to use taskkill to close all processes using taskkill command and delete directory , then copy directory using scp command.

The scp works fine and rmdir works and delete the directory.

The problem is the taskkill command returns no errors for GitHub action but no processes close and when testing this command taskkill inside Windows CMD it works and close everything, but nothing from GitHub Actions workflow.

name: Test Action

on: push

jobs:
  data_indexer:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v3 

    - name: Copy files to EC2
      run: |
        mkdir -p ~/.ssh
        ssh-keyscan IP >> ~/.ssh/known_hosts
        chmod 400 ./key.pem
        cat >> ~/.ssh/config <<END
        Host IP
          IdentityFile ./key.pem
          User Administrator
          PasswordAuthentication yes
          StrictHostKeyChecking no
          ForwardAgent yes
        END
        eval `ssh-agent -s`
        ssh-add ./key.pem
        ssh-add -L
        echo "The next command is SSH for coping"
        sshpass -p "password" ssh -i ./key.pem Administrator@IP " taskkill /F /FI \"STATUS eq RUNNING\" && rmdir C:\\Users\\Administrator\\Desktop\\data_indexer\\test "
        echo "The next command is SCP for coping"
        sshpass -p "password" scp -i ./key.pem -r ./ECR_folder Administrator@IP:C:\\Users\\Administrator\\Desktop\\data_indexer\\test

Upvotes: 0

Views: 50

Answers (0)

Related Questions