临时抱佛脚 (臨時抱佛腳) línshí bào fó jiǎo

línshí bào fó jiǎo set phrase to clasp the Buddha's feet when danger arises
Domain: Proverb 谚语
Notes: Figuratively, to profess devotion only when in trouble, doing things at the last minute, or making a hasty last-minute effort (CC-CEDICT '臨時抱佛腳'; Guoyu '臨時抱佛腳')

Also contained in

平时不烧香,临时抱佛脚