"I can't believe I did that"
You say you can't believe you did something you weren’t proud of because of the attachment you have to an idea of who you are.
Unfortunately, as humans, we can falter.
We are capable of doing things that contradict what we had earlier committed to.
We can seek truth, but often don’t because of the personal and social pain involved.
In and of itself, that's not a problem. The problem is that by telling yourself you can't believe what you did, you redefine the idea of who you now think you are. You give yourself a new image and identity - albeit a detrimental one.
Instead of saying 'I can't believe I did that,' change it to 'That happened, now, what do I do?'
Let go of the guilt and regret and reassign an acceptance of who you truly are - despite what just happened.