For this quest, you can warn Desdemona of the Railroad and/or Maxson of the Brotherhood. Even if you chose not to warn any of them, the battle for Bunker Hill will still be between the three factions. To trigger the battle, you have to talk to the courser X4-18 in an alley near Bunker Hill. Once he begins the assault
This is a big three-way battle between The Institute, Railroad, and Brotherhood of Steel forces even if you haven't informed the other two groups. In this battle, there are three possible outcomes depending on the affiliation you want to follow:
If you're a member of the three factions, their forces will generally ignore you and they'll fight amongst themselves. Be careful since raiders and some supermutants may join the fray. Make your way to the escaped synths and decide their fate. If you strayed away from The Institute's original objectives for this quest, Father will confront you on top of the CIT ruins. Depending on your answers, it may Lead to the immediate and permanent banishment from the Institute.
The main gate will be closed so you'll have to enter through the small side door to the west. From there, head inside the main building and enter through the trapdoor on the floor. The three forces will continue engaging in the basement hall. Continue following the straightforward path until you reach the four synths. You'll have the option how to deal with them. If you decide to let them go, the courser will turn hostile and you'll have to kill it.
If you killed the courser, you can leave the area even when there's still a battle going on and fast-travel to the CIT Ruins. You have to head to the rooftop and talk to Father. If you claim that you're ambushed, you'll still remain part of The Institute and the next quest will become available. Also, after this quest, talk to Kessler, Bunker Hill's mayor to turn this place as your new settlement.