You need DM buy-in, or this will not work
You are asking to get a "RAW" reading to approach your DM with. Unfortunately all the rules involved here are somewhat ambiguous or even contradictory, and strictly RAW this will not work. You have to work this out with your DM.
- It is not clear what the distance is across dimensional boundaries (it likely only works with a portable hole, not a bag of holding)
- It is not clear if you can store a conjuration spell (that makes a creature appear in a space)
- RAW, the conjuration spell will fail once triggered, even if you can store it
- It is not clear if you would control the spirit, even if you could summon it
Even if it all works, this will be a costly strategy to run, both in actions and gold needed.
Moving the glyph
Glyph of Warding says:
If you choose an object, that object must remain in its place; if the object is moved more than 10 feet from where you cast this spell, the glyph is broken, and the spell ends without being triggered.
So the idea with a bag of holding will not work. The distance between dimensions is usually considered infinite. Thus, if you put your object into the bag, or if you take it out, it will have moved more than 10 feet from where it was, to another dimension, and the glyph will be broken.
It is a little trickier with portable hole, where you need your DM to agree it is OK to consider the distance to be normal distance through the opening of the open hole. In that case, you can cast the glyph on the wall of the hole - then you do not have to move it, as the wall is in another dimension staying put, and when you open the hole and cast summon undead in range to trigger it, the trigger is in range and the glyph will summon an undead spirit.
Storing summon undead
There is the question if you can even store a summon undead into a glyph, because you can only store spells that target a single creature or an area. The targeting rules are unfortunatley rather vague. The normal spellcasting rules do not allow you to even target an area, they only allow you to target
creatures, objects, or a point of origin for an area of effect
A point of origin for an area of effect is not an area, it is a point. So technically, NO spell in the entire game can fullfill the criterium that they "target an area", and we have to interpret what this means. It could mean that it needs to be a spell that targets a point of origin for an area, or it could be a spell that mentions an area. Both are valid interpretations. Summon undead, similar to other conjuration spells says about the spririt,
It manifests in an unoccupied space that you can see within range.
and an unoccupied space is an area on the battlemap, of 5x5 feet. The glyph is intended to allow storing conjuration spells, else the clause about hostile conjured creatures would not make sense or be needed.
So, my conclusion is that you could store a conjuration spell that makes a creature appear in a space in glyph of warding, as that is the only way to read the rules that works. This question has answers that posit the clause is for future spells not yet written, but that doesn't sound convincing to me: the way the conjuration mechanics work, they conjure the creatures into spaces, and any future spells would be likely to follow the same template.
Casting summon undead from the glyph
Unfortunately, glyph of warding also says that
If the spell affects an area, the area is centered on that creature.
"That creature" being the creature that triggerd the spell. So the space that the spirit would have to be summoned into will be the space of the triggering creature, not an unoccupied space, and so the summons will fail, even if you can store the spell. And this happens to be true for all the conjuration spells that target a space. So strict RAW, successfully casting summoning spells from a glyph, even though it is clearly intended, based on the mechanics of the glyph cannot work. It would be up to your DM to fix this.
Controlling of summon undead
You need to be the caster if you want to command the summoned undead. It is not clear who the caster is for a spell triggered by a glyph of warding. That is because the spell is cast twice: once when you cast it into the glyph (here you are the caster), and once more when it is cast when the glyph is triggered:
When the glyph is triggered, the stored spell is cast. […] If the spell summons hostile creatures or creates harmful objects or traps, they appear as close as possible to the intruder and attack it.
So who is the caster in that case? Is it still you? Or is it the glyph? I think it most likely is still you, as the glyph would not be able to make any decisions for a spell it released, like issuing commands to a summoned creature, because it ends on triggering: "Once a glyph is triggered, this spell ends." But this is not explicit, so again up to your DM.
The undead spirit from summon undead is not hostile, so the clause that it will attack "the intruder", that is, the triggering creature, will not apply - thankfully, otherwise it might end up attacking you, because you triggered the glyph.
Practical issues
So for any chance this to work you need to have a portable hole in the first place. That is a Rare magic item, and unless you are very lucky, you won’t have one on fifth level. According to the games guidance, by level 6 you would expect to have one uncommon item and a few consumables. To have even a bag of holding across a normal party is not a given, unless your DM allows magic shops and buying one.
There also is the problem that opening a portable hole, like taking something from the bag, requires a full action, so you will not be able to cast summon undead yourself on the first round of combat. That is a huge cost, as most fights only take 3-4 rounds.
And there is the 200 gp cost on the glyph. At level 5, if you follow the guidelines for treasure, your character would have found about 650 gp worth of treasure. 200 gp is a significant outlay at the point, considering you have to spend 300 gp of that on a golden skull for summon undead. You might be able to do this exactly once, unless you have a more generous DM.
So, overall, even if your DM agrees to play ball, this is a not that great a tactic, certainly not something to create your whole character concept around.
P.S. I think the trope of summoned guardians from a magical trap like the glyph is a classic, and in my home game I prefer it to work. So as a DM I allow storing summons in a glyph, and the creatures appear in a space next to the creature that triggered it. I have this work for both the players, and for their opponents (in that latter case, I of course am not limited to explain how things work with book spells). So if I were your DM, you could do this, but you likely would not have the needed portable hole to pull it off on level 5. Maybe somewhere in tier 3. Your DM's mileage may vary.