You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lot of common tasks in a workflow triggered by a push event involves comparing the states of the branch before and after the push event. For this, one needs to fetch the git history of all commits contained in the push event, plus the last commit before the push.
However, this action only provides the fetch-depth parameter, which inputs the number of commits to fetch, but this information is not easily accessible. As far as I understand, the current solution is to fetch the entire history every time, using fetch-depth=0, but that seems like a waste of bandwidth and run time.
The push event payload does contain the list of commits as an array, but there is no native function in GitHub Actions to count the length of an array, otherwise one could do something like:
Alternatively, one could write an extra step before using checkout to count the number of commits in the payload, e.g. using Python or bash scripts, but that seems a bit too hacky for such a common task.
Wouldn't it be possible to provide the option to fetch the git history up to a certain commit hash?
In that case, in a push event one could do something like this:
on: pushsteps:
- uses: actions/checkout@v3with:
- fetch-depth-ref: ${{ github.event.before }}
The text was updated successfully, but these errors were encountered:
AAriam
changed the title
Support providing fetch-depth as commit hash
Support providing commit hash for fetch-depthSep 1, 2023
I guess another common reference would be the commit of the last successful build. Third-party solutions exist to obtain that hash so that subsequent steps can make use of it, but the checkout step would still have to fetch all commit in the first place.
A lot of common tasks in a workflow triggered by a
push
event involves comparing the states of the branch before and after the push event. For this, one needs to fetch the git history of all commits contained in the push event, plus the last commit before the push.However, this action only provides the
fetch-depth
parameter, which inputs the number of commits to fetch, but this information is not easily accessible. As far as I understand, the current solution is to fetch the entire history every time, usingfetch-depth=0
, but that seems like a waste of bandwidth and run time.The push event payload does contain the list of commits as an array, but there is no native function in GitHub Actions to count the length of an array, otherwise one could do something like:
Alternatively, one could write an extra step before using checkout to count the number of commits in the payload, e.g. using Python or bash scripts, but that seems a bit too hacky for such a common task.
Wouldn't it be possible to provide the option to fetch the git history up to a certain commit hash?
In that case, in a push event one could do something like this:
The text was updated successfully, but these errors were encountered: