We asked, "Messenger of Allah, will we be held accountable for what we did during the days of ignorance?"The Messenger of Allah ﷺ replied, "Whoever does good in Islam will not be held accountable for what he did during the days of ignorance, but whoever does evil will be held accountable for both the former and the latter."
حدثنا محمد بن عبد الله بن نمير حدثنا وكيع وأبي عن الأعمش عن شقيق
قلنا يا رسول الله أنؤاخذ بما كنا نعمل في الجاهلية فقال رسول الله ﷺ من أحسن في الإسلام لم يؤاخذ بما كان في الجاهلية ومن أساء أخذ بالأول والآخر
Bukhari narrated it in the chapter "Calling Apostates to Repent, etc.," section "The sin of one who associates partners with Allah, and its punishment in this world and the next," hadith 6921, from the hadith of Amash, through his chain, and Muslim, in the chapter of Faith, section "Is one held accountable for the deeds of the pre-Islamic era," hadith 120/190, from Ibn Numayr, through his chain.