This actually won’t work properly. If a commit is aborted (either via this script or canceled) the commit hashes won’t line up when you try to re-deploy. Example:
commit A - deploys
commit B - canceled by user
trigger rebuild from admin - script compares commit A hash (cached) to commit B hash (current) and sees they are different. Proceeds with git diff which shows no changes. Rebuild from admin does not occur.
Any help here?