No, good deeds are not accepted by Allāh if a person commits shirk (polytheism). In Islam, shirk—associating partners with Allāh—is the most severe sin, and it nullifies any good deeds performed alongside it. Allāh emphasizes this in the Qur’an, warning that polytheism voids all acts of worship and devotion, as true worship must be directed to Him alone.
Allāh says:
“If they had associated others with Him, then all that they used to do would have been in vain.”
— Surah Al-An’am (6:88)
And also:
“Indeed, Allāh does not forgive associating partners with Him, but He forgives anything else for whom He wills.”
— Surah An-Nisa (4:48)