The Messenger of Allah ﷺ said, "Hasten to do good deeds before tribulations come like stretches of dark night. A man will wake up as a believer and reach evening as a disbeliever, or reach evening as a believer and wake up as a disbeliever, selling his faith for some worldly gain."
حدثنا قتيبة حدثنا عبد العزيز بن محمد عن العلاء بن عبد الرحمن عن أبيه
أن رسول الله ﷺ قال بادروا بالأعمال فتنا كقطع الليل المظلم يصبح الرجل مؤمنا ويمسي كافرا ويمسي مؤمنا ويصبح كافرا يبيع أحدهم دينه بعرض من الدنيا
Muslim also narrated it in the Book of Faith, the chapter on encouraging haste in doing good deeds before troubles crowd in, hadith no. 118, from the hadith of Ala, through the same route.