GITHUB_SHA_SHORT returning variable length
gustavovalverde opened this issue ยท 6 comments
Describe the bug
@rlespinasse sometimes this action is getting a SHA with a length of 7 and sometimes with a length of 8, which crashes some actions.
See this examples:
Correct len(7) for GITHUB_SHA_SHORT: https://github.com/ZcashFoundation/zebra/runs/5618372155?check_suite_focus=true#step:3:977
Wrong len(8) for GITHUB_SHA_SHORT: https://github.com/ZcashFoundation/zebra/runs/5618372108?check_suite_focus=true#step:3:1017
This happens in the same action, almost duplicating the same steps
To Reproduce
Use @v4
of this action
Expected behavior
Always return the same length for the GITHUB_SHA_SHORT
The variable length is a git
feature, it gets longer as the repository gets larger:
- https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---shortlength
- https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreabbrev
It's hard to get a fixed length of 7 using git
command-line options. But setting git
's core.abbrev
config to 7 might do what you want here.
There are also some suggestions to manually get a short SHA from the full SHA here:
https://github.community/t/add-short-sha-to-github-context/16418/12
But some of them don't seem to work in GitHub Action expressions.
In this context, it's a bug
introduced in v4.0.1 in order to fix the difference between v3 (hard-setting at 8) and v4 versions (default git abbrev behavior).
In order to fix
this, I will restore the default behavior from git, but enable the configuration of it.
As @teor2345's find on shortsha action, this action uses a similar action shortify-git-revision
to do the job.
๐ This issue has been resolved in version 4.2.0 ๐
The release is available on GitHub release
Your semantic-release bot ๐ฆ๐
Thank you @rlespinasse