i want to make a continuos delivery for my EC2 instance in every git push.
For this i write the "update_server.bat" that works perfectly when manually executed:
scp -i "my-pem-file.pem" update.sh ec2-user@ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com:/home/ec2-user/.
ssh -i "my-pem-file.pem" ec2-user@ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com "sudo bash ./update.sh"
as you see, it executes "update.sh" in the EC2 instance after uploading it.
cd portfolio
git pull
sudo -H pip3 install -r requirements.txt
sudo kill $(pgrep -f 'main.py')
nohup sudo python3 main.py &> /dev/null &
exit
now i just want the ".git/hooks/post-push" to execute my "update_server.bat" but NOTHING i tried worked (I've done 18 pushes with different codes and nothing works, not even the echo tests). take a look at some codes that i tested:
#!/bin/sh
cmd.exe /c ./update_server.cmd
#!/bin/sh
REPO_DIR="$(git rev-parse --show-toplevel)"
UPDATE_SCRIPT_PATH="$REPO_DIR/aws_access/update_server.cmd"
cmd.exe /c "$UPDATE_SCRIPT_PATH"
#!/bin/sh
C:\Windows\System32\cmd.exe /c ./update_server.cmd
#!/Windows/System32/cmd
./update_server.cmd
#!/Windows/System32/cmd.exe
./update_server.cmd
i tried renaming .bat to .cmd and removed "@echo off" from my script, and many many many other adjusts, but with no success. I really need help with this, what is the problem here? I'm using Windows 11.