1
0
mirror of synced 2025-12-30 03:01:36 -05:00
Files
docs/script/deployment/create-staging-app-name.js
James M. Greene 12134aa84b Use staging app name module for content changes table generation (#21805)
* Use the 'script/deployment/create-staging-app-name' module when creating the content changes table comments

* Remove the shebang from the non-runnable script helper module
2021-09-29 09:00:19 -07:00

19 lines
525 B
JavaScript

import GithubSlugger from 'github-slugger'
const slugify = GithubSlugger.slug
const APP_NAME_MAX_LENGTH = 30
export default function ({ prefix = 'gha', repo, pullNumber, branch }) {
return (
`${prefix}-${repo}-${pullNumber}--${slugify(branch)}`
// Shorten the string to the max allowed length
.slice(0, APP_NAME_MAX_LENGTH)
// Convert underscores to dashes
.replace(/_/g, '-')
// Remove trailing dashes
.replace(/-+$/, '')
// Make it all lowercase
.toLowerCase()
)
}