If you often read about people from the past and think why do people know about their good deeds! Then know that this is because these people were Imams and people of status, and if such people tell others about their good deeds it is never considered as boasting. Rather it is a means to encourage others to be like them.
The other reason is that they actually never told people about their good deeds and people just found out somehow. And they never performed the good deed in order to be praised. For such people our beloved Prophet (peace be upon him) said:
تلك عاجل بشرى المؤمن
That is early glad tidings for the believer.