Is your feature request related to a problem? Please describe.
We rely on slugs a lot for various use cases (Docker Image Tags, FS Directories, branch names for automation, ...) but with the current implementation (we rely on GITHUB_REF_POINT most of the time) the sluggified version can lead to collisions in naming.
Describe the solution you'd like
I would love to see an input to optionally append a hash into the final slugged string so something like feature/some-random-branch-name-with-some-very-long-name-which-will-be-sluggified could become feature-some-random-branch-name-with-some-very-long-nam-cd4df5 instead of "just cutting it" into feature-some-random-branch-name-with-some-very-long-name-which.
Hash length could be defaulting to 8 characters taking sha1 into consideration it should be safe enough eventually.
Describe alternatives you've considered
I'm currently using the following workaround which feels a bit hacky and doesn't really do the job for short branch names (eg. main) as appending the hash isn't really required for those (it'll consistently result in main-19b01681 but it's not required):
- name: Slugify GitHub Environment Variables
uses: rlespinasse/github-slug-action@v5
with:
prefix: 'CI_'
slug-maxlength: '54'
- name: Append hash to CI_GITHUB_REF_POINT
id: hashed_head_ref
run: |
if [[ $(echo ${{ env.CI_GITHUB_REF_POINT_SLUG }} | wc -c | awk '{print $1}') -ge 54 ]]; then
echo hashed_head_ref="${{ env.CI_GITHUB_REF_POINT_SLUG }}-$(echo ${{ env.CI_GITHUB_REF_POINT }} | sha1sum | cut -c 1-8)" >> $GITHUB_OUTPUT
else
echo hashed_head_ref="${{ env.CI_GITHUB_REF_POINT_SLUG }}" >> $GITHUB_OUTPUT
fi
(edited for clarity/workaround improvements)
Is your feature request related to a problem? Please describe.
We rely on slugs a lot for various use cases (Docker Image Tags, FS Directories, branch names for automation, ...) but with the current implementation (we rely on
GITHUB_REF_POINTmost of the time) the sluggified version can lead to collisions in naming.Describe the solution you'd like
I would love to see an input to optionally append a hash into the final slugged string so something like
feature/some-random-branch-name-with-some-very-long-name-which-will-be-sluggifiedcould becomefeature-some-random-branch-name-with-some-very-long-nam-cd4df5instead of "just cutting it" intofeature-some-random-branch-name-with-some-very-long-name-which.Hash length could be defaulting to 8 characters taking sha1 into consideration it should be safe enough eventually.
Describe alternatives you've considered
I'm currently using the following workaround which feels a bit hacky and doesn't really do the job for short branch names (eg.
main) as appending the hash isn't really required for those (it'll consistently result inmain-19b01681but it's not required):(edited for clarity/workaround improvements)