Exporting only one animation to gltf from multiple objects each with an action
Not sure why but I got it to work by grouping the channels using this code:
for obj in bpy.context.selected_objects:
    new_group=obj.animation_data.action.groups.new(&quot;ChGroup&quot;)
    for fc in obj.animation_data.action.fcurves:
        fc.group=new_group

And then exporting to gltf without selecting NLA Track:
bpy.ops.export_scene.gltf(export_format='GLB', filepath=filepath, export_nla_strips =False )

Now there is only one animation in the gltf (the color is different too but that's unrelated):