You need DM buy-in, and even then, this is pretty costly
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.
It is also ambiguous 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, 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? That’s not clear. 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.
PS. There is the question if you can even store a summon undead into a glyph. The targeting rules are a bit vague, but my take is that conjuration spells that have a range in feet target the creatures they conjure — the glyph is clearly intended to allow storing conjuration spells, else the clause about hostile conjured creatures attacking the intruder would not make sense.