When survival is at stake, all the virtue signalling goes out of the window.
At that moment of time, living by higher values gets you slaughtered. For dharma to prevail adharmic things have to be done.
Do what needs to be done, ensure your survival and then you can self reflect in all the bad things you had to do, and feel shame.
If you want to ensure that you want to live by higher values, you need to put the mechanisms in place like not having adharmi people and ideologies to take precedence in your society.