I wrongly assumed that you use custom build phase hooks. I used them in the past to enrich build-arguments with meta information I used in the image labels.
Do the same builds work with the github actions you have in your repo?
I am not really familiar with python, but if there is a chance to get debug information during script execution you might want to enable it, to track down the root cause.
It could indeed the resource limits for the automated build. I couldn’t find resource limits in the official documentation. Though, If found an old forum post about it Automated Build resource restrictions - #2. I have no idea whether these limits still apply. A 2GB resource limit could indeed cause your python process to be oom-killed if its usage is above the resource limit.
I would suggest to open a ticket at Dockerhub’s support and ask for clearification.