Imagine torrential rains and a child is drowning in rushing flood waters. Should you jump in to try to save the child? There are three outcomes if you do: You emerge with the child; you emerge without the child; you drown in the attempt. Regardless, would you be heroic for trying to save the child? No. Even with a positive outcome you were being foolish and irresponsible.
The thought of saving the child is noble. But unless you are very good at swimming in rushing water, and few of us are, you put yourself in imminent danger. Do good for others, but think twice if your choice is a reckless one.
So if you have been in a situation where you could have done a good deed, but you didn’t because it put you at serious risk, don’t think you were bad for not trying. Be a hero when you can, but don’t be an irresponsible fool.