Ok, solved it
I added this snippet after _bake_all
method, it pushes humanoid actions into NLA so they can be exported by Gltf add on.
rig = bpy.data.objects['rig_humanoid']
# bpy.context.scene.objects.active = rig //removed in blender 2.8!
bpy.context.view_layer.objects.active = rig
rig.animation_data_create()
for action in bpy.data.actions:
if action.name.startswith("h_"):
rig.animation_data.action = bpy.data.actions[action.name]
bpy.context.area.type = 'DOPESHEET_EDITOR'
bpy.context.space_data.mode = 'ACTION'
bpy.ops.action.push_down()