dnd 5e – Does casting a spell that frightens / lies to an enemy count as "affecting" them for the purpose of Sanctuary?

There are multiple considerations here

Is the target an enemy?

Sanctuary specifies that a enemy It can not be affected. It says nothing about neutral or allied characters:

If the protected creature makes an attack, cast a spell that affects a enemy, or hurt another creature, this spell ends.

In the case of the villagers, are they hostile? If not, then he would allow himself to cast a spell that directly affects them, although doing so could provoke the villagers, which would mean that more spells would be against hostile creatures and, therefore, they would end the Sanctuary.

Does the spell affect the target or does it produce an effect that the target reacts to?

Illusion minor says (in part):

Create a sound or an image of an object that lasts the duration. The illusion ends soon if you discard it as an action or if you cast this spell again.

The minor illusion does not target a creature or specify an "area of ​​effect." Create an image It affects a creature only in the sense that pleasant music or a sad story affects it. This is different from the sense of the rule of affecting a creature like ball of fire make.

Create bonfire CAN end the spell, but not necessarily so

Create Bonfire says:

You conjure a magical bonfire that fills a 5-foot cube. Any creature in the space of the fire must pass a Dexterity salvation or receive 1d8 of fire damage. A creature must also make salvation when it moves into the space of the stake or ends its turn there.

Create Bonfire produces the same kind of affection as a minor illusion, in the sense that a creature can experience it as a stimulus (being "affected by"). This means you do not throw the fire under a creature. However, if the creature moves in the space of the bonfire (for example, to investigate), it would cause the creature to be affected by fire in the sense of the rule (receiving damage), which would do Finish the sanctuary's spell.