mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-05-18 20:51:48 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c099abd97 | ||
|
|
6c93fcbf53 | ||
|
|
38c43d3f60 | ||
|
|
275eb0d01d |
36
.github/workflows/build.yml
vendored
36
.github/workflows/build.yml
vendored
@@ -63,6 +63,24 @@ jobs:
|
||||
echo "Short SHA variables"
|
||||
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
||||
echo " pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
|
||||
- name: Case Sensitive Output
|
||||
run: |
|
||||
echo "Slug variables"
|
||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_CS }}"
|
||||
echo " repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}"
|
||||
echo " repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}"
|
||||
echo " ref : ${{ env.GITHUB_REF_SLUG_CS }}"
|
||||
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG_CS }}"
|
||||
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG_CS }}"
|
||||
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG_CS }}"
|
||||
echo "Slug URL variables"
|
||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL_CS }}"
|
||||
echo " repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}"
|
||||
echo " repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}"
|
||||
echo " ref : ${{ env.GITHUB_REF_SLUG_URL_CS }}"
|
||||
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL_CS }}"
|
||||
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}"
|
||||
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}"
|
||||
|
||||
win-test:
|
||||
runs-on: windows-latest
|
||||
@@ -93,3 +111,21 @@ jobs:
|
||||
echo "Short SHA variables"
|
||||
echo " sha : $env:GITHUB_SHA_SHORT"
|
||||
echo " pull request sha : $env:GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT"
|
||||
- name: Case Sensitive Output
|
||||
run: |
|
||||
echo "Slug variables"
|
||||
echo " repository : $env:GITHUB_REPOSITORY_SLUG_CS"
|
||||
echo " repository owner : $env:GITHUB_REPOSITORY_OWNER_PART_SLUG_CS"
|
||||
echo " repository name : $env:GITHUB_REPOSITORY_NAME_PART_SLUG_CS"
|
||||
echo " ref : $env:GITHUB_REF_SLUG_CS"
|
||||
echo " head ref : $env:GITHUB_HEAD_REF_SLUG_CS"
|
||||
echo " base ref : $env:GITHUB_BASE_REF_SLUG_CS"
|
||||
echo " event ref : $env:GITHUB_EVENT_REF_SLUG_CS"
|
||||
echo "Slug URL variables"
|
||||
echo " repository : $env:GITHUB_REPOSITORY_SLUG_URL_CS"
|
||||
echo " repository owner : $env:GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS"
|
||||
echo " repository name : $env:GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS"
|
||||
echo " ref : $env:GITHUB_REF_SLUG_URL_CS"
|
||||
echo " head ref : $env:GITHUB_HEAD_REF_SLUG_URL_CS"
|
||||
echo " base ref : $env:GITHUB_BASE_REF_SLUG_URL_CS"
|
||||
echo " event ref : $env:GITHUB_EVENT_REF_SLUG_URL_CS"
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
# [3.4.0](http://github.com/rlespinasse/github-slug-action/compare/3.3.0...3.4.0) (2021-03-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add _CS suffix to keep value case-sensitive ([6c93fcb](http://github.com/rlespinasse/github-slug-action/commit/6c93fcbf53da9c6415bd7f5e37579b488f34339e))
|
||||
|
||||
# [3.3.0](http://github.com/rlespinasse/github-slug-action/compare/3.2.0...3.3.0) (2021-01-25)
|
||||
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ This GitHub Action will expose the slug/short values of [some GitHub environment
|
||||
- `SLUG_URL` on a variable to have a `slug` variable compliant to be used in an URL (Like `SLUG` but `.` is also replaced by `-`)
|
||||
- `SHORT` on a variable will limit the string size to 8 characters (useful for _sha_ value)
|
||||
- `<KEY>_PART` on a variable will give a part of a variable defined by a key
|
||||
_ `<VAR>_CS` on others variables to keep the value case-sensitive
|
||||
|
||||
</p>
|
||||
</details>
|
||||
@@ -70,6 +71,8 @@ Check for more [examples][3] (OS usage, URL use, ...)
|
||||
|
||||
### Slug variables
|
||||
|
||||
**NOTE:** `_CS` suffix available
|
||||
|
||||
| Variable | Slug version of | Description |
|
||||
| ------------------------------------------------------------------------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------- |
|
||||
| [GITHUB_REPOSITORY_SLUG](docs/slug-variables.md#github_repository_slug) | GITHUB_REPOSITORY | The owner and repository name. |
|
||||
@@ -82,6 +85,8 @@ Check for more [examples][3] (OS usage, URL use, ...)
|
||||
|
||||
### Slug URL variables
|
||||
|
||||
**NOTE:** `_CS` suffix available
|
||||
|
||||
| Variable | Slug URL version of | Description |
|
||||
| --------------------------------------------------------------------------------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------- |
|
||||
| [GITHUB_REPOSITORY_SLUG_URL](docs/slug-url-variables.md#github_repository_slug_url) | GITHUB_REPOSITORY | The owner and repository name. |
|
||||
|
||||
@@ -1,36 +1,48 @@
|
||||
import {slug} from '../src/slug'
|
||||
import {slug, slug_cs} from '../src/slug'
|
||||
|
||||
function test_slug(input: string, expected: string) {
|
||||
let actual = slug(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
function test_slug_cs(input: string, expected: string) {
|
||||
let actual = slug_cs(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
test('slug: a word', () => {
|
||||
test_slug('word', 'word')
|
||||
test_slug_cs('word', 'word')
|
||||
})
|
||||
|
||||
test('slug: a string', () => {
|
||||
test_slug('basic-string', 'basic-string')
|
||||
test_slug_cs('basic-string', 'basic-string')
|
||||
})
|
||||
|
||||
test('slug: a string in camel case', () => {
|
||||
test_slug('camelCase', 'camelcase')
|
||||
test_slug_cs('camelCase', 'camelCase')
|
||||
})
|
||||
|
||||
test('slug: a path', () => {
|
||||
test_slug('path/to/something', 'path-to-something')
|
||||
test_slug_cs('path/to/something', 'path-to-something')
|
||||
})
|
||||
|
||||
test('slug: a number', () => {
|
||||
test_slug('4.2', '4.2')
|
||||
test_slug_cs('4.2', '4.2')
|
||||
})
|
||||
|
||||
test('slug: special caracter', () => {
|
||||
test_slug('feat-(!è§-caracter', 'feat------caracter')
|
||||
test('slug: special character', () => {
|
||||
test_slug('feat-(!è§-character', 'feat------character')
|
||||
test_slug_cs('feat-(!è§-character', 'feat------character')
|
||||
})
|
||||
|
||||
test('slug: trailing', () => {
|
||||
test_slug('-feat-trailing-', 'feat-trailing')
|
||||
test_slug_cs('-feat-trailing-', 'feat-trailing')
|
||||
})
|
||||
|
||||
test('slug: a very long string', () => {
|
||||
@@ -38,6 +50,10 @@ test('slug: a very long string', () => {
|
||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
||||
)
|
||||
test_slug_cs(
|
||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-more'
|
||||
)
|
||||
})
|
||||
|
||||
test('slug: short string after trailing', () => {
|
||||
@@ -45,4 +61,8 @@ test('slug: short string after trailing', () => {
|
||||
'-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters-',
|
||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
||||
)
|
||||
test_slug_cs(
|
||||
'-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters-',
|
||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-more'
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,49 +1,67 @@
|
||||
import {slugref} from '../src/slug'
|
||||
import {slugref, slugref_cs} from '../src/slug'
|
||||
|
||||
function test_slug_ref(input: string, expected: string) {
|
||||
function test_slugref(input: string, expected: string) {
|
||||
let actual = slugref(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
function test_slugref_cs(input: string, expected: string) {
|
||||
let actual = slugref_cs(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
test('slug_ref:: master branch', () => {
|
||||
test_slug_ref('refs/heads/master', 'master')
|
||||
test_slugref('refs/heads/master', 'master')
|
||||
test_slugref_cs('refs/heads/master', 'master')
|
||||
})
|
||||
|
||||
test('slug_ref: a feature branch', () => {
|
||||
test_slug_ref('refs/heads/feat/new_feature', 'feat-new-feature')
|
||||
test_slugref('refs/heads/feat/new_feature', 'feat-new-feature')
|
||||
test_slugref_cs('refs/heads/feat/new_feature', 'feat-new-feature')
|
||||
})
|
||||
|
||||
test('slug_ref: a fix branch', () => {
|
||||
test_slug_ref('refs/heads/fix/issue_number', 'fix-issue-number')
|
||||
test_slugref('refs/heads/fix/issue_number', 'fix-issue-number')
|
||||
test_slugref_cs('refs/heads/fix/issue_number', 'fix-issue-number')
|
||||
})
|
||||
|
||||
test('slug_ref: a simple tag', () => {
|
||||
test_slug_ref('refs/tags/v1.0.0', 'v1.0.0')
|
||||
test_slugref('refs/tags/v1.0.0', 'v1.0.0')
|
||||
test_slugref_cs('refs/tags/v1.0.0', 'v1.0.0')
|
||||
})
|
||||
|
||||
test('slug_ref: a complex tag', () => {
|
||||
test_slug_ref('refs/tags/product@1.0.0-rc.2', 'product-1.0.0-rc.2')
|
||||
test_slugref('refs/tags/product@1.0.0-rc.2', 'product-1.0.0-rc.2')
|
||||
test_slugref_cs('refs/tags/product@1.0.0-rc.2', 'product-1.0.0-rc.2')
|
||||
})
|
||||
|
||||
test('slug_ref: a reference with upper case letters', () => {
|
||||
test_slug_ref('refs/heads/New_Awesome_Product', 'new-awesome-product')
|
||||
test_slugref('refs/heads/New_Awesome_Product', 'new-awesome-product')
|
||||
test_slugref_cs('refs/heads/New_Awesome_Product', 'New-Awesome-Product')
|
||||
})
|
||||
|
||||
test('slug_ref: test trailing', () => {
|
||||
test_slug_ref('refs/heads/-trailing-feat-', 'trailing-feat')
|
||||
test_slugref('refs/heads/-trailing-feat-', 'trailing-feat')
|
||||
test_slugref_cs('refs/heads/-trailing-feat-', 'trailing-feat')
|
||||
})
|
||||
|
||||
test('slug_ref: test refs inside string', () => {
|
||||
test_slug_ref('refs/heads/-refs/tags/feature/-', 'refs-tags-feature')
|
||||
test_slugref('refs/heads/-refs/tags/feature/-', 'refs-tags-feature')
|
||||
test_slugref_cs('refs/heads/-refs/tags/feature/-', 'refs-tags-feature')
|
||||
})
|
||||
|
||||
test('slug_ref: a very long name', () => {
|
||||
test_slug_ref(
|
||||
test_slugref(
|
||||
'refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
||||
)
|
||||
test_slugref_cs(
|
||||
'refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-more'
|
||||
)
|
||||
})
|
||||
|
||||
test('slug_ref: on pull-request ref', () => {
|
||||
test_slug_ref('refs/pull/branch', 'branch')
|
||||
test_slugref('refs/pull/branch', 'branch')
|
||||
test_slugref_cs('refs/pull/branch', 'branch')
|
||||
})
|
||||
|
||||
@@ -1,37 +1,52 @@
|
||||
import {slugurl} from '../src/slug'
|
||||
import {slugurl, slugurl_cs} from '../src/slug'
|
||||
|
||||
function test_slug_url(input: string, expected: string) {
|
||||
function test_slugurl(input: string, expected: string) {
|
||||
let actual = slugurl(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
function test_slugurl_cs(input: string, expected: string) {
|
||||
let actual = slugurl_cs(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
test('slug_url: a word', () => {
|
||||
test_slug_url('word', 'word')
|
||||
test_slugurl('word', 'word')
|
||||
test_slugurl_cs('word', 'word')
|
||||
})
|
||||
|
||||
test('slug_url: a string', () => {
|
||||
test_slug_url('basic-string', 'basic-string')
|
||||
test_slugurl('basic-string', 'basic-string')
|
||||
test_slugurl_cs('basic-string', 'basic-string')
|
||||
})
|
||||
|
||||
test('slug_url: a string in camel case', () => {
|
||||
test_slug_url('camelCase', 'camelcase')
|
||||
test_slugurl('camelCase', 'camelcase')
|
||||
test_slugurl_cs('camelCase', 'camelCase')
|
||||
})
|
||||
|
||||
test('slug_url: a path', () => {
|
||||
test_slug_url('path/to/something', 'path-to-something')
|
||||
test_slugurl('path/to/something', 'path-to-something')
|
||||
test_slugurl_cs('path/to/something', 'path-to-something')
|
||||
})
|
||||
|
||||
test('slug_url: a number', () => {
|
||||
test_slug_url('4.2', '4-2')
|
||||
test_slugurl('4.2', '4-2')
|
||||
test_slugurl_cs('4.2', '4-2')
|
||||
})
|
||||
|
||||
test('slug_url: trailing', () => {
|
||||
test_slug_url('.path.to.', 'path-to')
|
||||
test_slugurl('.path.to.', 'path-to')
|
||||
test_slugurl_cs('.path.to.', 'path-to')
|
||||
})
|
||||
|
||||
test('slug_url: a very long string', () => {
|
||||
test_slug_url(
|
||||
test_slugurl(
|
||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
||||
)
|
||||
test_slugurl_cs(
|
||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-more'
|
||||
)
|
||||
})
|
||||
|
||||
@@ -1,49 +1,67 @@
|
||||
import {slugurlref} from '../src/slug'
|
||||
import {slugurlref, slugurlref_cs} from '../src/slug'
|
||||
|
||||
function test_slug_url_ref(input: string, expected: string) {
|
||||
function test_slugurlref(input: string, expected: string) {
|
||||
let actual = slugurlref(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
function test_slugurlref_cs(input: string, expected: string) {
|
||||
let actual = slugurlref_cs(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
test('slug_url_ref: master branch', () => {
|
||||
test_slug_url_ref('refs/heads/master', 'master')
|
||||
test_slugurlref('refs/heads/master', 'master')
|
||||
test_slugurlref_cs('refs/heads/master', 'master')
|
||||
})
|
||||
|
||||
test('slug_url_ref: a feature branch', () => {
|
||||
test_slug_url_ref('refs/heads/feat/new_feature', 'feat-new-feature')
|
||||
test_slugurlref('refs/heads/feat/new_feature', 'feat-new-feature')
|
||||
test_slugurlref_cs('refs/heads/feat/new_feature', 'feat-new-feature')
|
||||
})
|
||||
|
||||
test('slug_url_ref: a fix branch', () => {
|
||||
test_slug_url_ref('refs/heads/fix/issue_number', 'fix-issue-number')
|
||||
test_slugurlref('refs/heads/fix/issue_number', 'fix-issue-number')
|
||||
test_slugurlref_cs('refs/heads/fix/issue_number', 'fix-issue-number')
|
||||
})
|
||||
|
||||
test('slug_url_ref: a simple tag', () => {
|
||||
test_slug_url_ref('refs/tags/v1.0.0', 'v1-0-0')
|
||||
test_slugurlref('refs/tags/v1.0.0', 'v1-0-0')
|
||||
test_slugurlref_cs('refs/tags/v1.0.0', 'v1-0-0')
|
||||
})
|
||||
|
||||
test('slug_url_ref: a complex tag', () => {
|
||||
test_slug_url_ref('refs/tags/product@1.0.0-rc.2', 'product-1-0-0-rc-2')
|
||||
test_slugurlref('refs/tags/product@1.0.0-rc.2', 'product-1-0-0-rc-2')
|
||||
test_slugurlref_cs('refs/tags/product@1.0.0-rc.2', 'product-1-0-0-rc-2')
|
||||
})
|
||||
|
||||
test('slug_url_ref: a reference with upper case letters', () => {
|
||||
test_slug_url_ref('refs/heads/New_Awesome_Product', 'new-awesome-product')
|
||||
test_slugurlref('refs/heads/New_Awesome_Product', 'new-awesome-product')
|
||||
test_slugurlref_cs('refs/heads/New_Awesome_Product', 'New-Awesome-Product')
|
||||
})
|
||||
|
||||
test('slug_url_ref: a very long name', () => {
|
||||
test_slug_url_ref(
|
||||
test_slugurlref(
|
||||
'refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
||||
)
|
||||
test_slugurlref_cs(
|
||||
'refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-more'
|
||||
)
|
||||
})
|
||||
|
||||
test('slug_url_ref: test trailing', () => {
|
||||
test_slug_url_ref('refs/heads/-an-awesome-Feature-', 'an-awesome-feature')
|
||||
test_slugurlref('refs/heads/-an-awesome-Feature-', 'an-awesome-feature')
|
||||
test_slugurlref_cs('refs/heads/-an-awesome-Feature-', 'an-awesome-Feature')
|
||||
})
|
||||
|
||||
test('slug_url_ref: test trailing with dot', () => {
|
||||
test_slug_url_ref('refs/heads/.an-awesome-Feature.', 'an-awesome-feature')
|
||||
test_slugurlref('refs/heads/.an-awesome-Feature.', 'an-awesome-feature')
|
||||
test_slugurlref_cs('refs/heads/.an-awesome-Feature.', 'an-awesome-Feature')
|
||||
})
|
||||
|
||||
test('slug_url_ref: on pull-request ref', () => {
|
||||
test_slug_url_ref('refs/pull/branch', 'branch')
|
||||
test_slugurlref('refs/pull/branch', 'branch')
|
||||
test_slugurlref_cs('refs/pull/branch', 'branch')
|
||||
})
|
||||
|
||||
146
dist/index.js
vendored
146
dist/index.js
vendored
@@ -114,22 +114,36 @@ const GITHUB_REPOSITORY_NAME_PART = 'GITHUB_REPOSITORY_NAME_PART';
|
||||
* Slugged outputs environments variables keys
|
||||
*/
|
||||
const GITHUB_REPOSITORY_SLUG = 'GITHUB_REPOSITORY_SLUG';
|
||||
const GITHUB_REPOSITORY_SLUG_CS = 'GITHUB_REPOSITORY_SLUG_CS';
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG = 'GITHUB_REPOSITORY_OWNER_PART_SLUG';
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG_CS = 'GITHUB_REPOSITORY_OWNER_PART_SLUG_CS';
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG = 'GITHUB_REPOSITORY_NAME_PART_SLUG';
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG_CS = 'GITHUB_REPOSITORY_NAME_PART_SLUG_CS';
|
||||
const GITHUB_REF_SLUG = 'GITHUB_REF_SLUG';
|
||||
const GITHUB_REF_SLUG_CS = 'GITHUB_REF_SLUG_CS';
|
||||
const GITHUB_HEAD_REF_SLUG = 'GITHUB_HEAD_REF_SLUG';
|
||||
const GITHUB_HEAD_REF_SLUG_CS = 'GITHUB_HEAD_REF_SLUG_CS';
|
||||
const GITHUB_BASE_REF_SLUG = 'GITHUB_BASE_REF_SLUG';
|
||||
const GITHUB_BASE_REF_SLUG_CS = 'GITHUB_BASE_REF_SLUG_CS';
|
||||
const GITHUB_EVENT_REF_SLUG = 'GITHUB_EVENT_REF_SLUG';
|
||||
const GITHUB_EVENT_REF_SLUG_CS = 'GITHUB_EVENT_REF_SLUG_CS';
|
||||
/**
|
||||
* URL-Slugged outputs environments variables keys
|
||||
*/
|
||||
const GITHUB_REPOSITORY_SLUG_URL = 'GITHUB_REPOSITORY_SLUG_URL';
|
||||
const GITHUB_REPOSITORY_SLUG_URL_CS = 'GITHUB_REPOSITORY_SLUG_URL_CS';
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG_URL = 'GITHUB_REPOSITORY_OWNER_PART_SLUG_URL';
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS = 'GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS';
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG_URL = 'GITHUB_REPOSITORY_NAME_PART_SLUG_URL';
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS = 'GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS';
|
||||
const GITHUB_REF_SLUG_URL = 'GITHUB_REF_SLUG_URL';
|
||||
const GITHUB_REF_SLUG_URL_CS = 'GITHUB_REF_SLUG_URL_CS';
|
||||
const GITHUB_HEAD_REF_SLUG_URL = 'GITHUB_HEAD_REF_SLUG_URL';
|
||||
const GITHUB_HEAD_REF_SLUG_URL_CS = 'GITHUB_HEAD_REF_SLUG_URL_CS';
|
||||
const GITHUB_BASE_REF_SLUG_URL = 'GITHUB_BASE_REF_SLUG_URL';
|
||||
const GITHUB_BASE_REF_SLUG_URL_CS = 'GITHUB_BASE_REF_SLUG_URL_CS';
|
||||
const GITHUB_EVENT_REF_SLUG_URL = 'GITHUB_EVENT_REF_SLUG_URL';
|
||||
const GITHUB_EVENT_REF_SLUG_URL_CS = 'GITHUB_EVENT_REF_SLUG_URL_CS';
|
||||
/**
|
||||
* Shorted outputs environments variables keys
|
||||
*/
|
||||
@@ -143,7 +157,9 @@ function run() {
|
||||
const eventData = yield Promise.resolve().then(() => __importStar(require(eventPath)));
|
||||
if (eventData.hasOwnProperty('ref')) {
|
||||
core.exportVariable(GITHUB_EVENT_REF_SLUG, slug_1.slugref(eventData.ref));
|
||||
core.exportVariable(GITHUB_EVENT_REF_SLUG_CS, slug_1.slugref_cs(eventData.ref));
|
||||
core.exportVariable(GITHUB_EVENT_REF_SLUG_URL, slug_1.slugurlref(eventData.ref));
|
||||
core.exportVariable(GITHUB_EVENT_REF_SLUG_URL_CS, slug_1.slugurlref_cs(eventData.ref));
|
||||
}
|
||||
else if (eventData.hasOwnProperty('pull_request')) {
|
||||
core.exportVariable(GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT, short_1.shortsha(eventData.pull_request.head.sha));
|
||||
@@ -152,17 +168,29 @@ function run() {
|
||||
exportFirstPart(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_OWNER_PART);
|
||||
exportSecondPart(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_NAME_PART);
|
||||
exportSlug(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG);
|
||||
exportSlugCS(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_CS);
|
||||
exportFirstPartSlug(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_OWNER_PART_SLUG);
|
||||
exportFirstPartSlugCS(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_OWNER_PART_SLUG_CS);
|
||||
exportSecondPartSlug(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_NAME_PART_SLUG);
|
||||
exportSecondPartSlugCS(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_NAME_PART_SLUG_CS);
|
||||
exportSlugUrl(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_URL);
|
||||
exportSlugUrlCS(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_URL_CS);
|
||||
exportFirstPartSlugUrl(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_OWNER_PART_SLUG_URL);
|
||||
exportFirstPartSlugUrlCS(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS);
|
||||
exportSecondPartSlugUrl(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_NAME_PART_SLUG_URL);
|
||||
exportSecondPartSlugUrlCS(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS);
|
||||
exportSlugRef(GITHUB_REF, GITHUB_REF_SLUG);
|
||||
exportSlugRefCS(GITHUB_REF, GITHUB_REF_SLUG_CS);
|
||||
exportSlugRef(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG);
|
||||
exportSlugRefCS(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG_CS);
|
||||
exportSlugRef(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG);
|
||||
exportSlugRefCS(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG_CS);
|
||||
exportSlugUrlRef(GITHUB_REF, GITHUB_REF_SLUG_URL);
|
||||
exportSlugUrlRefCS(GITHUB_REF, GITHUB_REF_SLUG_URL_CS);
|
||||
exportSlugUrlRef(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG_URL);
|
||||
exportSlugUrlRefCS(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG_URL_CS);
|
||||
exportSlugUrlRef(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG_URL);
|
||||
exportSlugUrlRefCS(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG_URL_CS);
|
||||
exportShortSha(GITHUB_SHA, GITHUB_SHA_SHORT);
|
||||
}
|
||||
catch (error) {
|
||||
@@ -182,12 +210,25 @@ function exportSecondPart(inputKey, separator, outputKey) {
|
||||
core.exportVariable(outputKey, partial_1.get_second_part(envVar, separator));
|
||||
}
|
||||
}
|
||||
function exportSlugCS(inputKey, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slug_1.slug_cs(envVar));
|
||||
}
|
||||
}
|
||||
function exportSlug(inputKey, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slug_1.slug(envVar));
|
||||
}
|
||||
}
|
||||
function exportFirstPartSlugCS(inputKey, separator, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
const value = partial_1.get_first_part(envVar, separator);
|
||||
core.exportVariable(outputKey, slug_1.slug_cs(value));
|
||||
}
|
||||
}
|
||||
function exportFirstPartSlug(inputKey, separator, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
@@ -195,6 +236,13 @@ function exportFirstPartSlug(inputKey, separator, outputKey) {
|
||||
core.exportVariable(outputKey, slug_1.slug(value));
|
||||
}
|
||||
}
|
||||
function exportSecondPartSlugCS(inputKey, separator, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
const value = partial_1.get_second_part(envVar, separator);
|
||||
core.exportVariable(outputKey, slug_1.slug_cs(value));
|
||||
}
|
||||
}
|
||||
function exportSecondPartSlug(inputKey, separator, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
@@ -202,18 +250,37 @@ function exportSecondPartSlug(inputKey, separator, outputKey) {
|
||||
core.exportVariable(outputKey, slug_1.slug(value));
|
||||
}
|
||||
}
|
||||
function exportSlugRefCS(inputKey, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slug_1.slugref_cs(envVar));
|
||||
}
|
||||
}
|
||||
function exportSlugRef(inputKey, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slug_1.slugref(envVar));
|
||||
}
|
||||
}
|
||||
function exportSlugUrlCS(inputKey, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slug_1.slugurl_cs(envVar));
|
||||
}
|
||||
}
|
||||
function exportSlugUrl(inputKey, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slug_1.slugurl(envVar));
|
||||
}
|
||||
}
|
||||
function exportFirstPartSlugUrlCS(inputKey, separator, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
const value = partial_1.get_first_part(envVar, separator);
|
||||
core.exportVariable(outputKey, slug_1.slugurl_cs(value));
|
||||
}
|
||||
}
|
||||
function exportFirstPartSlugUrl(inputKey, separator, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
@@ -221,6 +288,13 @@ function exportFirstPartSlugUrl(inputKey, separator, outputKey) {
|
||||
core.exportVariable(outputKey, slug_1.slugurl(value));
|
||||
}
|
||||
}
|
||||
function exportSecondPartSlugUrlCS(inputKey, separator, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
const value = partial_1.get_second_part(envVar, separator);
|
||||
core.exportVariable(outputKey, slug_1.slugurl_cs(value));
|
||||
}
|
||||
}
|
||||
function exportSecondPartSlugUrl(inputKey, separator, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
@@ -228,6 +302,12 @@ function exportSecondPartSlugUrl(inputKey, separator, outputKey) {
|
||||
core.exportVariable(outputKey, slug_1.slugurl(value));
|
||||
}
|
||||
}
|
||||
function exportSlugUrlRefCS(inputKey, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slug_1.slugurlref_cs(envVar));
|
||||
}
|
||||
}
|
||||
function exportSlugUrlRef(inputKey, outputKey) {
|
||||
const envVar = process.env[inputKey];
|
||||
if (envVar) {
|
||||
@@ -658,8 +738,19 @@ exports.get_second_part = get_second_part;
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.slugurlref = exports.slugurl = exports.slugref = exports.slug = void 0;
|
||||
exports.slugurlref = exports.slugurlref_cs = exports.slugurl = exports.slugurl_cs = exports.slugref = exports.slugref_cs = exports.slug = exports.slug_cs = void 0;
|
||||
const MAX_SLUG_STRING_SIZE = 63;
|
||||
/**
|
||||
* slug_cs will take envVar and then :
|
||||
* - replace any character by `-` except `0-9`, `a-z`, and `.`
|
||||
* - remove leading and trailing `-` character
|
||||
* - limit the string size to 63 characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
function slug_cs(envVar) {
|
||||
return trailHyphen(replaceAnyNonAlphanumericCharacter(envVar)).substring(0, MAX_SLUG_STRING_SIZE);
|
||||
}
|
||||
exports.slug_cs = slug_cs;
|
||||
/**
|
||||
* slug will take envVar and then :
|
||||
* - put the variable content in lower case
|
||||
@@ -669,12 +760,24 @@ const MAX_SLUG_STRING_SIZE = 63;
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
function slug(envVar) {
|
||||
return trailHyphen(replaceAnyNonAlphanumericCaracter(envVar.toLowerCase())).substring(0, MAX_SLUG_STRING_SIZE);
|
||||
return slug_cs(envVar.toLowerCase());
|
||||
}
|
||||
exports.slug = slug;
|
||||
/**
|
||||
* slug will take envVar and then :
|
||||
* - remove refs/(heads|tags)/
|
||||
* slugref_cs will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - replace any character by `-` except `0-9`, `a-z`, and `.`
|
||||
* - remove leading and trailing `-` character
|
||||
* - limit the string size to 63 characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
function slugref_cs(envVar) {
|
||||
return slug_cs(removeRef(envVar));
|
||||
}
|
||||
exports.slugref_cs = slugref_cs;
|
||||
/**
|
||||
* slugref will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - put the variable content in lower case
|
||||
* - replace any character by `-` except `0-9`, `a-z`, and `.`
|
||||
* - remove leading and trailing `-` character
|
||||
@@ -682,11 +785,22 @@ exports.slug = slug;
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
function slugref(envVar) {
|
||||
return slug(removeRef(envVar.toLowerCase()));
|
||||
return slugref_cs(envVar.toLowerCase());
|
||||
}
|
||||
exports.slugref = slugref;
|
||||
/**
|
||||
* slug will take envVar and then :
|
||||
* slugurl_cs will take envVar and then :
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading and trailing `-` character
|
||||
* - limit the string size to 63 characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
function slugurl_cs(envVar) {
|
||||
return slug_cs(replaceAnyDotToHyphen(envVar));
|
||||
}
|
||||
exports.slugurl_cs = slugurl_cs;
|
||||
/**
|
||||
* slugurl will take envVar and then :
|
||||
* - put the variable content in lower case
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading and trailing `-` character
|
||||
@@ -698,8 +812,20 @@ function slugurl(envVar) {
|
||||
}
|
||||
exports.slugurl = slugurl;
|
||||
/**
|
||||
* slug will take envVar and then :
|
||||
* - remove refs/(heads|tags)/
|
||||
* slugurlref_cs will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading and trailing `-` character
|
||||
* - limit the string size to 63 characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
function slugurlref_cs(envVar) {
|
||||
return slugurl_cs(slugref_cs(envVar));
|
||||
}
|
||||
exports.slugurlref_cs = slugurlref_cs;
|
||||
/**
|
||||
* slugurlref will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - put the variable content in lower case
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading and trailing `-` character
|
||||
@@ -713,8 +839,8 @@ exports.slugurlref = slugurlref;
|
||||
function trailHyphen(envVar) {
|
||||
return envVar.replace(RegExp('^-*', 'g'), '').replace(RegExp('-*$', 'g'), '');
|
||||
}
|
||||
function replaceAnyNonAlphanumericCaracter(envVar) {
|
||||
return envVar.replace(RegExp('[^a-z0-9.]', 'g'), '-');
|
||||
function replaceAnyNonAlphanumericCharacter(envVar) {
|
||||
return envVar.replace(RegExp('[^a-zA-Z0-9.]', 'g'), '-');
|
||||
}
|
||||
function replaceAnyDotToHyphen(envVar) {
|
||||
return envVar.replace(RegExp('[.]', 'g'), '-');
|
||||
|
||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -60,9 +60,13 @@ _If neither a branch or tag is available for the event type, the variable will n
|
||||
| refs/heads/main | main |
|
||||
| refs/heads/feat/new_feature | feat-new-feature |
|
||||
| refs/tags/v1.0.0 | v1-0-0 |
|
||||
| refs/pull/42-merge | 42-merge |
|
||||
| refs/tags/product@1.0.0-rc.2 | product-1-0-0-rc-2 |
|
||||
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||
|
||||
**Caution**: From v3.0.0 to v3.2.0 included, `GITHUB_REF_SLUG` have the wrong value on `pull_request` event.
|
||||
`refs/pull/42-merge` become `refs-pull-42-merge` instead of `42-merge`. The bug have been fixed in v3.3.0
|
||||
|
||||
## GITHUB_HEAD_REF_SLUG_URL
|
||||
|
||||
Slug URL the environment variable **GITHUB_HEAD_REF**
|
||||
|
||||
17293
package-lock.json
generated
17293
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -42,7 +42,7 @@
|
||||
"jest-circus": "^26.6.3",
|
||||
"js-yaml": "^3.14.1",
|
||||
"prettier": "^2.2.1",
|
||||
"semantic-release": "^17.3.4",
|
||||
"semantic-release": "^17.4.0",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "^3.9.7"
|
||||
},
|
||||
|
||||
136
src/main.ts
136
src/main.ts
@@ -1,5 +1,14 @@
|
||||
import * as core from '@actions/core'
|
||||
import {slugref, slug, slugurl, slugurlref} from './slug'
|
||||
import {
|
||||
slug,
|
||||
slug_cs,
|
||||
slugref,
|
||||
slugref_cs,
|
||||
slugurl,
|
||||
slugurl_cs,
|
||||
slugurlref,
|
||||
slugurlref_cs
|
||||
} from './slug'
|
||||
import {shortsha} from './short'
|
||||
import {get_first_part, get_second_part} from './partial'
|
||||
|
||||
@@ -26,25 +35,43 @@ const GITHUB_REPOSITORY_NAME_PART = 'GITHUB_REPOSITORY_NAME_PART'
|
||||
* Slugged outputs environments variables keys
|
||||
*/
|
||||
const GITHUB_REPOSITORY_SLUG = 'GITHUB_REPOSITORY_SLUG'
|
||||
const GITHUB_REPOSITORY_SLUG_CS = 'GITHUB_REPOSITORY_SLUG_CS'
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG = 'GITHUB_REPOSITORY_OWNER_PART_SLUG'
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG_CS =
|
||||
'GITHUB_REPOSITORY_OWNER_PART_SLUG_CS'
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG = 'GITHUB_REPOSITORY_NAME_PART_SLUG'
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG_CS =
|
||||
'GITHUB_REPOSITORY_NAME_PART_SLUG_CS'
|
||||
const GITHUB_REF_SLUG = 'GITHUB_REF_SLUG'
|
||||
const GITHUB_REF_SLUG_CS = 'GITHUB_REF_SLUG_CS'
|
||||
const GITHUB_HEAD_REF_SLUG = 'GITHUB_HEAD_REF_SLUG'
|
||||
const GITHUB_HEAD_REF_SLUG_CS = 'GITHUB_HEAD_REF_SLUG_CS'
|
||||
const GITHUB_BASE_REF_SLUG = 'GITHUB_BASE_REF_SLUG'
|
||||
const GITHUB_BASE_REF_SLUG_CS = 'GITHUB_BASE_REF_SLUG_CS'
|
||||
const GITHUB_EVENT_REF_SLUG = 'GITHUB_EVENT_REF_SLUG'
|
||||
const GITHUB_EVENT_REF_SLUG_CS = 'GITHUB_EVENT_REF_SLUG_CS'
|
||||
|
||||
/**
|
||||
* URL-Slugged outputs environments variables keys
|
||||
*/
|
||||
const GITHUB_REPOSITORY_SLUG_URL = 'GITHUB_REPOSITORY_SLUG_URL'
|
||||
const GITHUB_REPOSITORY_SLUG_URL_CS = 'GITHUB_REPOSITORY_SLUG_URL_CS'
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG_URL =
|
||||
'GITHUB_REPOSITORY_OWNER_PART_SLUG_URL'
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS =
|
||||
'GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS'
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG_URL =
|
||||
'GITHUB_REPOSITORY_NAME_PART_SLUG_URL'
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS =
|
||||
'GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS'
|
||||
const GITHUB_REF_SLUG_URL = 'GITHUB_REF_SLUG_URL'
|
||||
const GITHUB_REF_SLUG_URL_CS = 'GITHUB_REF_SLUG_URL_CS'
|
||||
const GITHUB_HEAD_REF_SLUG_URL = 'GITHUB_HEAD_REF_SLUG_URL'
|
||||
const GITHUB_HEAD_REF_SLUG_URL_CS = 'GITHUB_HEAD_REF_SLUG_URL_CS'
|
||||
const GITHUB_BASE_REF_SLUG_URL = 'GITHUB_BASE_REF_SLUG_URL'
|
||||
const GITHUB_BASE_REF_SLUG_URL_CS = 'GITHUB_BASE_REF_SLUG_URL_CS'
|
||||
const GITHUB_EVENT_REF_SLUG_URL = 'GITHUB_EVENT_REF_SLUG_URL'
|
||||
const GITHUB_EVENT_REF_SLUG_URL_CS = 'GITHUB_EVENT_REF_SLUG_URL_CS'
|
||||
|
||||
/**
|
||||
* Shorted outputs environments variables keys
|
||||
@@ -60,10 +87,15 @@ async function run(): Promise<void> {
|
||||
const eventData = await import(eventPath)
|
||||
if (eventData.hasOwnProperty('ref')) {
|
||||
core.exportVariable(GITHUB_EVENT_REF_SLUG, slugref(eventData.ref))
|
||||
core.exportVariable(GITHUB_EVENT_REF_SLUG_CS, slugref_cs(eventData.ref))
|
||||
core.exportVariable(
|
||||
GITHUB_EVENT_REF_SLUG_URL,
|
||||
slugurlref(eventData.ref)
|
||||
)
|
||||
core.exportVariable(
|
||||
GITHUB_EVENT_REF_SLUG_URL_CS,
|
||||
slugurlref_cs(eventData.ref)
|
||||
)
|
||||
} else if (eventData.hasOwnProperty('pull_request')) {
|
||||
core.exportVariable(
|
||||
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT,
|
||||
@@ -76,36 +108,64 @@ async function run(): Promise<void> {
|
||||
exportSecondPart(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_NAME_PART)
|
||||
|
||||
exportSlug(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG)
|
||||
exportSlugCS(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_CS)
|
||||
exportFirstPartSlug(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_OWNER_PART_SLUG
|
||||
)
|
||||
exportFirstPartSlugCS(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_OWNER_PART_SLUG_CS
|
||||
)
|
||||
exportSecondPartSlug(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_NAME_PART_SLUG
|
||||
)
|
||||
exportSecondPartSlugCS(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_NAME_PART_SLUG_CS
|
||||
)
|
||||
|
||||
exportSlugUrl(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_URL)
|
||||
exportSlugUrlCS(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_URL_CS)
|
||||
exportFirstPartSlugUrl(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_OWNER_PART_SLUG_URL
|
||||
)
|
||||
exportFirstPartSlugUrlCS(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS
|
||||
)
|
||||
exportSecondPartSlugUrl(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_NAME_PART_SLUG_URL
|
||||
)
|
||||
exportSecondPartSlugUrlCS(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS
|
||||
)
|
||||
|
||||
exportSlugRef(GITHUB_REF, GITHUB_REF_SLUG)
|
||||
exportSlugRefCS(GITHUB_REF, GITHUB_REF_SLUG_CS)
|
||||
exportSlugRef(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG)
|
||||
exportSlugRefCS(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG_CS)
|
||||
exportSlugRef(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG)
|
||||
exportSlugRefCS(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG_CS)
|
||||
|
||||
exportSlugUrlRef(GITHUB_REF, GITHUB_REF_SLUG_URL)
|
||||
exportSlugUrlRefCS(GITHUB_REF, GITHUB_REF_SLUG_URL_CS)
|
||||
exportSlugUrlRef(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG_URL)
|
||||
exportSlugUrlRefCS(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG_URL_CS)
|
||||
exportSlugUrlRef(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG_URL)
|
||||
exportSlugUrlRefCS(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG_URL_CS)
|
||||
|
||||
exportShortSha(GITHUB_SHA, GITHUB_SHA_SHORT)
|
||||
} catch (error) {
|
||||
@@ -135,6 +195,12 @@ function exportSecondPart(
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugCS(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slug_cs(envVar))
|
||||
}
|
||||
}
|
||||
function exportSlug(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
@@ -142,6 +208,18 @@ function exportSlug(inputKey: string, outputKey: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
function exportFirstPartSlugCS(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_first_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slug_cs(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportFirstPartSlug(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
@@ -154,6 +232,18 @@ function exportFirstPartSlug(
|
||||
}
|
||||
}
|
||||
|
||||
function exportSecondPartSlugCS(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_second_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slug_cs(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSecondPartSlug(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
@@ -166,6 +256,13 @@ function exportSecondPartSlug(
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugRefCS(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slugref_cs(envVar))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugRef(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
@@ -173,6 +270,12 @@ function exportSlugRef(inputKey: string, outputKey: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugUrlCS(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slugurl_cs(envVar))
|
||||
}
|
||||
}
|
||||
function exportSlugUrl(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
@@ -180,6 +283,18 @@ function exportSlugUrl(inputKey: string, outputKey: string): void {
|
||||
}
|
||||
}
|
||||
|
||||
function exportFirstPartSlugUrlCS(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_first_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slugurl_cs(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportFirstPartSlugUrl(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
@@ -192,6 +307,18 @@ function exportFirstPartSlugUrl(
|
||||
}
|
||||
}
|
||||
|
||||
function exportSecondPartSlugUrlCS(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_second_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slugurl_cs(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSecondPartSlugUrl(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
@@ -204,6 +331,13 @@ function exportSecondPartSlugUrl(
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugUrlRefCS(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slugurlref_cs(envVar))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugUrlRef(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
|
||||
69
src/slug.ts
69
src/slug.ts
@@ -1,5 +1,19 @@
|
||||
const MAX_SLUG_STRING_SIZE = 63
|
||||
|
||||
/**
|
||||
* slug_cs will take envVar and then :
|
||||
* - replace any character by `-` except `0-9`, `a-z`, and `.`
|
||||
* - remove leading and trailing `-` character
|
||||
* - limit the string size to 63 characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slug_cs(envVar: string): string {
|
||||
return trailHyphen(replaceAnyNonAlphanumericCharacter(envVar)).substring(
|
||||
0,
|
||||
MAX_SLUG_STRING_SIZE
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* slug will take envVar and then :
|
||||
* - put the variable content in lower case
|
||||
@@ -9,14 +23,24 @@ const MAX_SLUG_STRING_SIZE = 63
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slug(envVar: string): string {
|
||||
return trailHyphen(
|
||||
replaceAnyNonAlphanumericCaracter(envVar.toLowerCase())
|
||||
).substring(0, MAX_SLUG_STRING_SIZE)
|
||||
return slug_cs(envVar.toLowerCase())
|
||||
}
|
||||
|
||||
/**
|
||||
* slug will take envVar and then :
|
||||
* - remove refs/(heads|tags)/
|
||||
* slugref_cs will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - replace any character by `-` except `0-9`, `a-z`, and `.`
|
||||
* - remove leading and trailing `-` character
|
||||
* - limit the string size to 63 characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugref_cs(envVar: string): string {
|
||||
return slug_cs(removeRef(envVar))
|
||||
}
|
||||
|
||||
/**
|
||||
* slugref will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - put the variable content in lower case
|
||||
* - replace any character by `-` except `0-9`, `a-z`, and `.`
|
||||
* - remove leading and trailing `-` character
|
||||
@@ -24,11 +48,22 @@ export function slug(envVar: string): string {
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugref(envVar: string): string {
|
||||
return slug(removeRef(envVar.toLowerCase()))
|
||||
return slugref_cs(envVar.toLowerCase())
|
||||
}
|
||||
|
||||
/**
|
||||
* slug will take envVar and then :
|
||||
* slugurl_cs will take envVar and then :
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading and trailing `-` character
|
||||
* - limit the string size to 63 characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugurl_cs(envVar: string): string {
|
||||
return slug_cs(replaceAnyDotToHyphen(envVar))
|
||||
}
|
||||
|
||||
/**
|
||||
* slugurl will take envVar and then :
|
||||
* - put the variable content in lower case
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading and trailing `-` character
|
||||
@@ -40,8 +75,20 @@ export function slugurl(envVar: string): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* slug will take envVar and then :
|
||||
* - remove refs/(heads|tags)/
|
||||
* slugurlref_cs will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading and trailing `-` character
|
||||
* - limit the string size to 63 characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugurlref_cs(envVar: string): string {
|
||||
return slugurl_cs(slugref_cs(envVar))
|
||||
}
|
||||
|
||||
/**
|
||||
* slugurlref will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - put the variable content in lower case
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading and trailing `-` character
|
||||
@@ -56,8 +103,8 @@ function trailHyphen(envVar: string): string {
|
||||
return envVar.replace(RegExp('^-*', 'g'), '').replace(RegExp('-*$', 'g'), '')
|
||||
}
|
||||
|
||||
function replaceAnyNonAlphanumericCaracter(envVar: string): string {
|
||||
return envVar.replace(RegExp('[^a-z0-9.]', 'g'), '-')
|
||||
function replaceAnyNonAlphanumericCharacter(envVar: string): string {
|
||||
return envVar.replace(RegExp('[^a-zA-Z0-9.]', 'g'), '-')
|
||||
}
|
||||
|
||||
function replaceAnyDotToHyphen(envVar: string): string {
|
||||
|
||||
Reference in New Issue
Block a user