All HOA dues are dischargable in a Chapter 7 Bankruptcy as to you personally. The lien attaches to the title to the real estate covered by the HOA, so in order to keep the property, you would have to pay the lien. If the lien isn't paid, the HOA can foreclose, just as a mortgage company or tax authority could foreclose. But the HOA can only proceed against the property, they can't sue you to obtain money damages for the portion of the debt owed at the time you filed.
You may be technically responsible for paying the HOA dues that occurred after you filed the Bankruptcy.
I have just one more point to add to the previous answer. Yes, the home owners association has the legal right to foreclose against the property. But, it almost certainly will not file to foreclose.
Foreclosures are expensive. The lien is gaining interest. Why should the association pay big money to an attorney to foreclose? The better policy is usually to wait for you to sell or until the first mortgage holder files to foreclose.
In other words, as long as you you keep up payments on the first mortgage, the homeowners association almost certainly will refrain from filing to foreclose. There's nothing certain in life, but sometimes you have to play the odds when they are strongly in your favor. Good luck.