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 processec close and when testing this command “taskkill” inside windows CMD it works and close everything, but nothing from GitHub workflow
`name: Test Action
on:
push:
branches:
– branch
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`