GitHub Actions: git merge-base Fails with a Shallow Clone
The change analysis script cannot determine a common branch ancestor, even though repo works locally.
How to identify the source of the problem
Check the fetch-depeh setting in action/checkout and no history in the .git runner directory.
Check the workflow event type, permissions joba, run ID and first failed step.
Repair steps
Set a sufficient history of fetch-teph or download the needed branch before analyzing the diff.
How to Test Solution
Comparison of PR with base works without forcing force push and without missing ancestor.
Security and restrictions
Apply minimum token privileges and re-impotence. Do not remove main branch protection only for the convenience of the machine.