AkhileshNS / heroku-deploy

A simple github action that dynamically deploys an app to heroku
MIT License
972 stars 254 forks source link

Very long deployment times and logs when using `appdir` #175

Open oswaldoacauan opened 6 months ago

oswaldoacauan commented 6 months ago

We are currently in the middle of a migration from some of our apps to a monorepo and we noticed that the deployments for those apps got infinitely slower.

It went from an average of 2min per deployment to over 5min.

The logs are also massive (8000+ lines)instead of just showing the heroku build log (< 50 lines).

BEFORE image

AFTER image

avishnyak commented 3 months ago

I have run into this issue as well. The slowness is coming from the git subtree split command that is used whenever you provide an appdir. This runs through every commit of your repo to create a new version of your repo that ignores files outside of the appdir path.

appdir processes your entire git history one commit at a time for each release. With every commit, the time increases.

It is possible to speed this up! One option is to save a checkpoint every once in a while in your repo. I did so with this command: git subtree split --rejoin --squash --prefix=appdir master (important: do not add a ./ at the beginning of the appdir here). Once you commit this giant "special" commit, the subtree split command in this action will use that to speed up the process.

HOWEVER: You might run into another issue. If you run this action in a ubuntu-latest runner, it uses the dash shell with a configuration that limits recursion depth to 1000 by default. The git subtree split command seems to run into issues once you do the above procedure when run with this recursion limit.

Every action to speed up the git subtree split that I found made things even worse. The proper fix is to AVOID appdir at all costs and use a Buildpacks like https://github.com/timanovsky/subdir-heroku-buildpack instead. You push your whole repo to Heroku, then delete all but one folder. It's lightning fast in comparison to the appdir solution in this action.

nicolasvienot commented 3 months ago

We have the same issue; it started to be slow last week. From 2min to 30+ min. No changes on our side, we're using akhileshns/heroku-deploy@v3.13.15. We are indeed using the appdir option.