To explore the relationship between social support and sleep quality of community workers in Wuhan during the coronavirus disease 2019 (the COVID-19 infection epidemic), this research constructed a mediating effect model to explore the mediating psychological mechanism of social support influencing sleep quality of front-line community workers. A total of 500 front-line community workers in Wuhan were investigated. We used the perceived social support scale (PSSS), the Connor-Davidson Resilience Scale (CD-RISC), the perceived stress scale (PSS), and the Pittsburgh sleep quality index (PSQI) to measure social support, psychological resilience, perceived stress and sleep quality. Specifically, the higher the PSQI, the worse the sleep quality. Pearson correlation structural equation model was used to analyze the relationship between these factors. The results showed that: (1) There was a significant negative correlation between social support, psychological resilience, and perceived stress of community workers and PSQI, that means, the higher the level of social support, psychological resilience, and perceived stress, the higher the sleep quality. (2) Social support positively predicted psychological resilience and perceived stress, and perceived stress negatively predicted PSQI. (3) Social support can affect sleep quality through the mediating role of psychological resilience and perceived stress, and the mediating role includes two paths: the single mediating role of perceived stress and the chain mediating role of psychological resilience-perceived stress. (4) Gender moderates the relationship between social support and perceived stress, and the influence of social support on perceived stress of women is higher than that of men. Gender moderates the relationship between psychological resilience and PSQI, and only women's psychological resilience had a negatively predictive effect on PSQI, while men did not, which means that psychological resilience of female frontline community workers can positively predict sleep quality. This research reveals the relationship between social support and sleep quality and its mechanism and verifies that social support can indirectly affect physical health through psychological resilience and perceived stress. It provides reference suggestions and intervention guidance for improving the sleep quality of community workers.