actions / checkout

Action for checking out a repo
https://github.com/features/actions
MIT License
5.94k stars 1.77k forks source link

Question: any way to access current branch latest commit? #1944

Open kshpytsya opened 1 month ago

kshpytsya commented 1 month ago

As mentioned in #573, the checkout action does all it can to present, during repeated runs, the state of the checked out repo the way it was during the first run. The problem I am trying to solve is to detect whether the commit referenced by GITHUB_SHA is still the latest in the branch being processed, to be able to skip some deployment-like activities. Is there any way to get sha of current latest commit in specific branch without resorting to extra accesses to remote repo? Something like git log -1 --pretty=format:"%H" origin/main doesn't work due to a forced update done by the checkout action.

kshpytsya commented 1 month ago

Related: #520