Not acting out of fear of people

I usually perform righteous actions but sometimes I think that I am doing them so that people can talk about them whilst I am alive or when I die. Sometimes I leave off performing them altogether due to that. Please guide me.

No doubt that performing good deeds because of people is “riya” showing off. There is no doubt that the one who performs such actions in order to be seen by the people, his actions are futile, and this is from minor polytheism. The prophet ﷺ warned of this, but if the person began the action for the sake of Allaah, seeking the face of Allah, but then after he performs it he loves for people to speak about it and praise him, then most of the people of knowledge hold that this is impermissible and spoils the action. Some of the people of knowledge say “It does not harm” because Allaah vilifies the one who loves to be praised for actions that he did not do. But if he loves to be praised for that which he actually does, then this does not harm due to the understanding of His saying:
وَّيُحِبُّونَ أَن يُحۡمَدُواْ بِمَا لَم ۡيَفۡعَلُواْ
“They love to be praise for that which they do not do”
(Surah Ali-Imran/188)
The understanding of it is that the one who likes to be praised for that which he does not enter into this dispraise, so based upon this, there is no accountability on him but no doubt, to prevent your actions from the people’s observation is better for the completion of sincerity and attach and place your hope with Allah the Mighty and Majestic. This is because the people are not able to give him anything which Allah does not will. And know, that if the whole of creation were to gather together in order to harm you with something that Allah had not written, they will never be able to harm you. Likewise, if they gather together in order to benefit you with something, they would never be able to benefit you with something except if Allaah had written that for you. Ibn-ul Qayyam said in his book “al-Fawa’id” a priceless statement: If you intend to do an action then proceed to the love of praise and slaughter it with the knife of your action, and that the praise does not benefit or dispraise of anybody harms him, except for Allah’s. As is mentioned in a narration that a Bedouin came to the prophet peace be upon him and said: “My praise is an adornment and my dispraise is a disgrace”. So the prophet peace be upon him said to him: “That is Allah the Mighty and Majestic” (Tirmidhi/3267) So the fact that the servants have no effect on the Muslim in the results of his worship if he attaches his heart to Allah, this is from the completion and perfection of sincerity. So people need to pay close attention to this affair and observe one’s heart because intentions tend to roam and wander as the people of knowledge say. So, he should observe that and pay importance to it because he can be heedless of this and find that he has deficiency in his actions, rather, they may even cause him harm and Allah knows best.