Skip to content

Instantly share code, notes, and snippets.

@c0m1c5an5
Last active April 28, 2025 15:12
Show Gist options
  • Save c0m1c5an5/a4b41e808243cfd45592698180c8f938 to your computer and use it in GitHub Desktop.
Save c0m1c5an5/a4b41e808243cfd45592698180c8f938 to your computer and use it in GitHub Desktop.
GitLab CI Slugify Implementation Pure Bash
# Implementation of https://gitlab.com/gitlab-org/gitlab/-/blob/master/gems/gitlab-utils/lib/gitlab/utils.rb#L56
slugify() {
local reply
unset REPLY ERR
reply="${*,,}"
reply="${reply//[^a-z0-9]/-}"
reply="${reply:0:63}"
while [[ ${reply} == -* ]]; do reply="${reply#-}"; done
while [[ ${reply} == *- ]]; do reply="${reply%-}"; done
REPLY="${reply}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment