This study contributes to the field of sustainability by analyzing changes in firms following the adoption of new environmental protection laws to meet community sustainability needs. Focusing on the Chinese context, it examined the relationship between firms' environmental protection measures (i.e., corporate green behavior) and profitability (i.e., corporate tax avoidance). The moderating roles of environmental uncertainty and digital technology application in this relationship were also investigated. The findings offer insights into the complex dynamics linking firms’ environmental initiatives to their business outcomes and financial decisions within the framework of a sustainable community. Ultimately, this study highlights the importance and implications of sustainable practices for both the environment and corporate financial performance. Firms’ environmental behaviors are enablers of sustainable communities by deploying natural resources and creating a more resilient economy through active community participation in green production models.