mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-05-17 18:35:07 +00:00
refactor: remove all node related files
This commit is contained in:
committed by
Romain Lespinasse
parent
4405613430
commit
e13c7fcc34
@@ -1,3 +0,0 @@
|
|||||||
dist/
|
|
||||||
lib/
|
|
||||||
node_modules/
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
{
|
|
||||||
"plugins": ["jest", "@typescript-eslint"],
|
|
||||||
"extends": ["plugin:github/recommended"],
|
|
||||||
"parser": "@typescript-eslint/parser",
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 9,
|
|
||||||
"sourceType": "module",
|
|
||||||
"project": "./tsconfig.json"
|
|
||||||
},
|
|
||||||
"rules": {
|
|
||||||
"eslint-comments/no-use": "off",
|
|
||||||
"import/no-namespace": "off",
|
|
||||||
"no-unused-vars": "off",
|
|
||||||
"@typescript-eslint/no-unused-vars": "error",
|
|
||||||
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
|
|
||||||
"@typescript-eslint/no-require-imports": "error",
|
|
||||||
"@typescript-eslint/array-type": "error",
|
|
||||||
"@typescript-eslint/await-thenable": "error",
|
|
||||||
"@typescript-eslint/ban-ts-comment": "error",
|
|
||||||
"camelcase": "off",
|
|
||||||
"@typescript-eslint/consistent-type-assertions": "error",
|
|
||||||
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
|
|
||||||
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
|
||||||
"@typescript-eslint/no-array-constructor": "error",
|
|
||||||
"@typescript-eslint/no-empty-interface": "error",
|
|
||||||
"@typescript-eslint/no-explicit-any": "error",
|
|
||||||
"@typescript-eslint/no-extraneous-class": "error",
|
|
||||||
"@typescript-eslint/no-for-in-array": "error",
|
|
||||||
"@typescript-eslint/no-inferrable-types": "error",
|
|
||||||
"@typescript-eslint/no-misused-new": "error",
|
|
||||||
"@typescript-eslint/no-namespace": "error",
|
|
||||||
"@typescript-eslint/no-non-null-assertion": "warn",
|
|
||||||
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
||||||
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
|
||||||
"@typescript-eslint/no-useless-constructor": "error",
|
|
||||||
"@typescript-eslint/no-var-requires": "error",
|
|
||||||
"@typescript-eslint/prefer-for-of": "warn",
|
|
||||||
"@typescript-eslint/prefer-function-type": "warn",
|
|
||||||
"@typescript-eslint/prefer-includes": "error",
|
|
||||||
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
|
||||||
"@typescript-eslint/promise-function-async": "error",
|
|
||||||
"@typescript-eslint/require-array-sort-compare": "error",
|
|
||||||
"@typescript-eslint/restrict-plus-operands": "error",
|
|
||||||
"semi": "off",
|
|
||||||
"@typescript-eslint/semi": ["error", "never"],
|
|
||||||
"@typescript-eslint/type-annotation-spacing": "error",
|
|
||||||
"@typescript-eslint/unbound-method": "error"
|
|
||||||
},
|
|
||||||
"env": {
|
|
||||||
"node": true,
|
|
||||||
"es6": true,
|
|
||||||
"jest/globals": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2
.github/workflows/github-slug.yml
vendored
2
.github/workflows/github-slug.yml
vendored
@@ -10,8 +10,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- run: npm install
|
|
||||||
- run: npm run all
|
|
||||||
- uses: ./
|
- uses: ./
|
||||||
- name: Partial variables
|
- name: Partial variables
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
99
.gitignore
vendored
99
.gitignore
vendored
@@ -1,99 +0,0 @@
|
|||||||
# Dependency directory
|
|
||||||
node_modules
|
|
||||||
|
|
||||||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
|
||||||
# Logs
|
|
||||||
logs
|
|
||||||
*.log
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
lerna-debug.log*
|
|
||||||
|
|
||||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
|
||||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
|
||||||
|
|
||||||
# Runtime data
|
|
||||||
pids
|
|
||||||
*.pid
|
|
||||||
*.seed
|
|
||||||
*.pid.lock
|
|
||||||
|
|
||||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
|
||||||
lib-cov
|
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
|
||||||
coverage
|
|
||||||
*.lcov
|
|
||||||
|
|
||||||
# nyc test coverage
|
|
||||||
.nyc_output
|
|
||||||
|
|
||||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
|
||||||
.grunt
|
|
||||||
|
|
||||||
# Bower dependency directory (https://bower.io/)
|
|
||||||
bower_components
|
|
||||||
|
|
||||||
# node-waf configuration
|
|
||||||
.lock-wscript
|
|
||||||
|
|
||||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
|
||||||
build/Release
|
|
||||||
|
|
||||||
# Dependency directories
|
|
||||||
jspm_packages/
|
|
||||||
|
|
||||||
# TypeScript v1 declaration files
|
|
||||||
typings/
|
|
||||||
|
|
||||||
# TypeScript cache
|
|
||||||
*.tsbuildinfo
|
|
||||||
|
|
||||||
# Optional npm cache directory
|
|
||||||
.npm
|
|
||||||
|
|
||||||
# Optional eslint cache
|
|
||||||
.eslintcache
|
|
||||||
|
|
||||||
# Optional REPL history
|
|
||||||
.node_repl_history
|
|
||||||
|
|
||||||
# Output of 'npm pack'
|
|
||||||
*.tgz
|
|
||||||
|
|
||||||
# Yarn Integrity file
|
|
||||||
.yarn-integrity
|
|
||||||
|
|
||||||
# dotenv environment variables file
|
|
||||||
.env
|
|
||||||
.env.test
|
|
||||||
|
|
||||||
# parcel-bundler cache (https://parceljs.org/)
|
|
||||||
.cache
|
|
||||||
|
|
||||||
# next.js build output
|
|
||||||
.next
|
|
||||||
|
|
||||||
# nuxt.js build output
|
|
||||||
.nuxt
|
|
||||||
|
|
||||||
# vuepress build output
|
|
||||||
.vuepress/dist
|
|
||||||
|
|
||||||
# Serverless directories
|
|
||||||
.serverless/
|
|
||||||
|
|
||||||
# FuseBox cache
|
|
||||||
.fusebox/
|
|
||||||
|
|
||||||
# DynamoDB Local files
|
|
||||||
.dynamodb/
|
|
||||||
|
|
||||||
# OS metadata
|
|
||||||
.DS_Store
|
|
||||||
Thumbs.db
|
|
||||||
|
|
||||||
# Ignore built ts files
|
|
||||||
__tests__/runner/*
|
|
||||||
lib/**/*
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
dist/
|
|
||||||
lib/
|
|
||||||
node_modules/
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"printWidth": 80,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"useTabs": false,
|
|
||||||
"semi": false,
|
|
||||||
"singleQuote": true,
|
|
||||||
"trailingComma": "none",
|
|
||||||
"bracketSpacing": false,
|
|
||||||
"arrowParens": "avoid"
|
|
||||||
}
|
|
||||||
@@ -18,7 +18,7 @@ Include the relevant issue number if applicable.
|
|||||||
|
|
||||||
## Do you intend to add a new feature or change an existing one
|
## Do you intend to add a new feature or change an existing one
|
||||||
|
|
||||||
* Suggest your change by [opening a 'Feature request' issue][5] and start writing code (following the [developers guide](DEVELOPERS.md))
|
* Suggest your change by [opening a 'Feature request' issue][5]
|
||||||
|
|
||||||
## Do you have questions about the source code
|
## Do you have questions about the source code
|
||||||
|
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
# Developers guide
|
|
||||||
|
|
||||||
## Prepare
|
|
||||||
|
|
||||||
Install the dependencies
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Develop
|
|
||||||
|
|
||||||
Build the typescript and package it for distribution
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run build && npm run package
|
|
||||||
```
|
|
||||||
|
|
||||||
Run the tests
|
|
||||||
|
|
||||||
```bash
|
|
||||||
$ npm test
|
|
||||||
|
|
||||||
PASS ./index.test.js
|
|
||||||
✓ throws invalid number (3ms)
|
|
||||||
✓ wait 500 ms (504ms)
|
|
||||||
✓ test runs (95ms)
|
|
||||||
|
|
||||||
...
|
|
||||||
```
|
|
||||||
|
|
||||||
## Contribute
|
|
||||||
|
|
||||||
Before creating a commit, validate your changes and build the associated distribution files
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run all
|
|
||||||
```
|
|
||||||
14
README.md
14
README.md
@@ -18,7 +18,6 @@ This GitHub Action will expose the slug/short values of [some GitHub environment
|
|||||||
- [Slug variables](#slug-variables)
|
- [Slug variables](#slug-variables)
|
||||||
- [Slug URL variables](#slug-url-variables)
|
- [Slug URL variables](#slug-url-variables)
|
||||||
- [Short variables](#short-variables)
|
- [Short variables](#short-variables)
|
||||||
- [Contribute](#contribute)
|
|
||||||
- [Troubleshooting](#troubleshooting)
|
- [Troubleshooting](#troubleshooting)
|
||||||
- [One of the environment variables doesn't work as intended](#one-of-the-environment-variables-doesnt-work-as-intended)
|
- [One of the environment variables doesn't work as intended](#one-of-the-environment-variables-doesnt-work-as-intended)
|
||||||
- [An action could not be found at the URI](#an-action-could-not-be-found-at-the-uri)
|
- [An action could not be found at the URI](#an-action-could-not-be-found-at-the-uri)
|
||||||
@@ -60,6 +59,15 @@ Add this in your workflow
|
|||||||
uses: rlespinasse/github-slug-action@v4.x
|
uses: rlespinasse/github-slug-action@v4.x
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or with a prefix
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Inject slug/short variables
|
||||||
|
uses: rlespinasse/github-slug-action@v4.x
|
||||||
|
with:
|
||||||
|
prefix: CI_
|
||||||
|
```
|
||||||
|
|
||||||
Check for more [examples][examples] (OS usage, URL use, ...)
|
Check for more [examples][examples] (OS usage, URL use, ...)
|
||||||
|
|
||||||
**Tip:** Use [Dependabot][dependabot] to maintain your `github-slug-action` version updated in your GitHub workflows.
|
**Tip:** Use [Dependabot][dependabot] to maintain your `github-slug-action` version updated in your GitHub workflows.
|
||||||
@@ -118,10 +126,6 @@ Check for more [examples][examples] (OS usage, URL use, ...)
|
|||||||
| [GITHUB_SHA_SHORT](docs/short-variables.md#github_sha_short) | GITHUB_SHA | The commit SHA that triggered the workflow. |
|
| [GITHUB_SHA_SHORT](docs/short-variables.md#github_sha_short) | GITHUB_SHA | The commit SHA that triggered the workflow. |
|
||||||
| [GITHUB_EVENT<br>_PULL_REQUEST<br>_HEAD_SHA_SHORT](docs/short-variables.md#github_event_pull_request_head_sha_short) | _github.event<br>.pull_request<br>.head.sha_ | The commit SHA on pull request that trigger workflow.<br>Only set for [following webhook events][webhooks-and-events]<ul><li>`pull_request`</li><li>`pull_request_review`</li><li>`pull_request_review_comment`</li><li>`pull_request_target`</li></ul> |
|
| [GITHUB_EVENT<br>_PULL_REQUEST<br>_HEAD_SHA_SHORT](docs/short-variables.md#github_event_pull_request_head_sha_short) | _github.event<br>.pull_request<br>.head.sha_ | The commit SHA on pull request that trigger workflow.<br>Only set for [following webhook events][webhooks-and-events]<ul><li>`pull_request`</li><li>`pull_request_review`</li><li>`pull_request_review_comment`</li><li>`pull_request_target`</li></ul> |
|
||||||
|
|
||||||
## Contribute
|
|
||||||
|
|
||||||
Follow [Developers guide](DEVELOPERS.md)
|
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
### One of the environment variables doesn't work as intended
|
### One of the environment variables doesn't work as intended
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
import {sep} from 'path'
|
|
||||||
import {get_first_part, get_second_part} from '../src/partial'
|
|
||||||
|
|
||||||
function test_get_first_part(
|
|
||||||
input: string,
|
|
||||||
separator: string,
|
|
||||||
expected: string
|
|
||||||
) {
|
|
||||||
let actual = get_first_part(input, separator)
|
|
||||||
expect(actual).toEqual(expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_get_second_part(
|
|
||||||
input: string,
|
|
||||||
separator: string,
|
|
||||||
expected: string
|
|
||||||
) {
|
|
||||||
let actual = get_second_part(input, separator)
|
|
||||||
expect(actual).toEqual(expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
test('get_first_part', () => {
|
|
||||||
test_get_first_part('first/second', '/', 'first')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('get_second_part', () => {
|
|
||||||
test_get_second_part('first/second', '/', 'second')
|
|
||||||
})
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import {shortsha} from '../src/short'
|
|
||||||
|
|
||||||
function test_short_sha(input: string, expected: string) {
|
|
||||||
let actual = shortsha(input)
|
|
||||||
expect(actual).toEqual(expected)
|
|
||||||
}
|
|
||||||
|
|
||||||
test('short_sha: long hash', () => {
|
|
||||||
test_short_sha('a35a1a486a260cfd99c5b6f8c6034a2929ba9b3f', 'a35a1a48')
|
|
||||||
})
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
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 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', () => {
|
|
||||||
test_slug(
|
|
||||||
'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', () => {
|
|
||||||
test_slug(
|
|
||||||
'-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,67 +0,0 @@
|
|||||||
import {slugref, slugref_cs} from '../src/slug'
|
|
||||||
|
|
||||||
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_slugref('refs/heads/master', 'master')
|
|
||||||
test_slugref_cs('refs/heads/master', 'master')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_ref: a feature branch', () => {
|
|
||||||
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_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_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_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_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_slugref('refs/heads/-trailing-feat-', 'trailing-feat')
|
|
||||||
test_slugref_cs('refs/heads/-trailing-feat-', 'trailing-feat')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_ref: test refs inside string', () => {
|
|
||||||
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_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_slugref('refs/pull/branch', 'branch')
|
|
||||||
test_slugref_cs('refs/pull/branch', 'branch')
|
|
||||||
})
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
import {slugurl, slugurl_cs} from '../src/slug'
|
|
||||||
|
|
||||||
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_slugurl('word', 'word')
|
|
||||||
test_slugurl_cs('word', 'word')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: a string', () => {
|
|
||||||
test_slugurl('basic-string', 'basic-string')
|
|
||||||
test_slugurl_cs('basic-string', 'basic-string')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: a string in camel case', () => {
|
|
||||||
test_slugurl('camelCase', 'camelcase')
|
|
||||||
test_slugurl_cs('camelCase', 'camelCase')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: a path', () => {
|
|
||||||
test_slugurl('path/to/something', 'path-to-something')
|
|
||||||
test_slugurl_cs('path/to/something', 'path-to-something')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: a number', () => {
|
|
||||||
test_slugurl('4.2', '4-2')
|
|
||||||
test_slugurl_cs('4.2', '4-2')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: trailing', () => {
|
|
||||||
test_slugurl('.path.to.', 'path-to')
|
|
||||||
test_slugurl_cs('.path.to.', 'path-to')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url: a very long string', () => {
|
|
||||||
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,67 +0,0 @@
|
|||||||
import {slugurlref, slugurlref_cs} from '../src/slug'
|
|
||||||
|
|
||||||
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_slugurlref('refs/heads/master', 'master')
|
|
||||||
test_slugurlref_cs('refs/heads/master', 'master')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('slug_url_ref: a feature branch', () => {
|
|
||||||
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_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_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_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_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_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_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_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_slugurlref('refs/pull/branch', 'branch')
|
|
||||||
test_slugurlref_cs('refs/pull/branch', 'branch')
|
|
||||||
})
|
|
||||||
947
dist/index.js
vendored
947
dist/index.js
vendored
@@ -1,947 +0,0 @@
|
|||||||
require('./sourcemap-register.js');module.exports =
|
|
||||||
/******/ (function(modules, runtime) { // webpackBootstrap
|
|
||||||
/******/ "use strict";
|
|
||||||
/******/ // The module cache
|
|
||||||
/******/ var installedModules = {};
|
|
||||||
/******/
|
|
||||||
/******/ // The require function
|
|
||||||
/******/ function __webpack_require__(moduleId) {
|
|
||||||
/******/
|
|
||||||
/******/ // Check if module is in cache
|
|
||||||
/******/ if(installedModules[moduleId]) {
|
|
||||||
/******/ return installedModules[moduleId].exports;
|
|
||||||
/******/ }
|
|
||||||
/******/ // Create a new module (and put it into the cache)
|
|
||||||
/******/ var module = installedModules[moduleId] = {
|
|
||||||
/******/ i: moduleId,
|
|
||||||
/******/ l: false,
|
|
||||||
/******/ exports: {}
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // Execute the module function
|
|
||||||
/******/ var threw = true;
|
|
||||||
/******/ try {
|
|
||||||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
||||||
/******/ threw = false;
|
|
||||||
/******/ } finally {
|
|
||||||
/******/ if(threw) delete installedModules[moduleId];
|
|
||||||
/******/ }
|
|
||||||
/******/
|
|
||||||
/******/ // Flag the module as loaded
|
|
||||||
/******/ module.l = true;
|
|
||||||
/******/
|
|
||||||
/******/ // Return the exports of the module
|
|
||||||
/******/ return module.exports;
|
|
||||||
/******/ }
|
|
||||||
/******/
|
|
||||||
/******/
|
|
||||||
/******/ __webpack_require__.ab = __dirname + "/";
|
|
||||||
/******/
|
|
||||||
/******/ // the startup function
|
|
||||||
/******/ function startup() {
|
|
||||||
/******/ // Load entry module and return exports
|
|
||||||
/******/ return __webpack_require__(109);
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // run startup
|
|
||||||
/******/ return startup();
|
|
||||||
/******/ })
|
|
||||||
/************************************************************************/
|
|
||||||
/******/ ({
|
|
||||||
|
|
||||||
/***/ 87:
|
|
||||||
/***/ (function(module) {
|
|
||||||
|
|
||||||
module.exports = require("os");
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 109:
|
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const core = __importStar(__webpack_require__(186));
|
|
||||||
const slug_1 = __webpack_require__(565);
|
|
||||||
const short_1 = __webpack_require__(213);
|
|
||||||
const partial_1 = __webpack_require__(373);
|
|
||||||
const SEPARATOR = '/';
|
|
||||||
/**
|
|
||||||
* Inputs environments variables keys from Github actions job
|
|
||||||
* see https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
|
||||||
*/
|
|
||||||
const GITHUB_REPOSITORY = 'GITHUB_REPOSITORY';
|
|
||||||
const GITHUB_REF = 'GITHUB_REF';
|
|
||||||
const GITHUB_HEAD_REF = 'GITHUB_HEAD_REF';
|
|
||||||
const GITHUB_BASE_REF = 'GITHUB_BASE_REF';
|
|
||||||
const GITHUB_SHA = 'GITHUB_SHA';
|
|
||||||
const GITHUB_EVENT_PATH = 'GITHUB_EVENT_PATH';
|
|
||||||
/**
|
|
||||||
* Partial outputs environments variables keys
|
|
||||||
*/
|
|
||||||
const GITHUB_REPOSITORY_OWNER_PART = 'GITHUB_REPOSITORY_OWNER_PART';
|
|
||||||
const GITHUB_REPOSITORY_NAME_PART = 'GITHUB_REPOSITORY_NAME_PART';
|
|
||||||
/**
|
|
||||||
* New environments variables keys
|
|
||||||
*/
|
|
||||||
const GITHUB_REF_NAME = 'GITHUB_REF_NAME';
|
|
||||||
/**
|
|
||||||
* 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';
|
|
||||||
const GITHUB_REF_NAME_SLUG = 'GITHUB_REF_NAME_SLUG';
|
|
||||||
const GITHUB_REF_NAME_SLUG_CS = 'GITHUB_REF_NAME_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';
|
|
||||||
const GITHUB_REF_NAME_SLUG_URL = 'GITHUB_REF_NAME_SLUG_URL';
|
|
||||||
const GITHUB_REF_NAME_SLUG_URL_CS = 'GITHUB_REF_NAME_SLUG_URL_CS';
|
|
||||||
/**
|
|
||||||
* Shorted outputs environments variables keys
|
|
||||||
*/
|
|
||||||
const GITHUB_SHA_SHORT = 'GITHUB_SHA_SHORT';
|
|
||||||
const GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT = 'GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT';
|
|
||||||
function run() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
try {
|
|
||||||
const eventPath = process.env[GITHUB_EVENT_PATH];
|
|
||||||
if (eventPath) {
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
exportBranchName();
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
core.setFailed(error.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function exportFirstPart(inputKey, separator, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, partial_1.get_first_part(envVar, separator));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportSecondPart(inputKey, separator, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
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) {
|
|
||||||
const value = partial_1.get_first_part(envVar, separator);
|
|
||||||
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) {
|
|
||||||
const value = partial_1.get_second_part(envVar, separator);
|
|
||||||
core.exportVariable(outputKey, slug_1.slug(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportSlugRefCS(inputKey, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
exportSlugRefCSValue(envVar, outputKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportSlugRefCSValue(envVar, outputKey) {
|
|
||||||
core.exportVariable(outputKey, slug_1.slugref_cs(envVar));
|
|
||||||
}
|
|
||||||
function exportSlugRef(inputKey, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
exportSlugRefValue(envVar, outputKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportSlugRefValue(envVar, outputKey) {
|
|
||||||
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) {
|
|
||||||
const value = partial_1.get_first_part(envVar, separator);
|
|
||||||
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) {
|
|
||||||
const value = partial_1.get_second_part(envVar, separator);
|
|
||||||
core.exportVariable(outputKey, slug_1.slugurl(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportSlugUrlRefCS(inputKey, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
exportSlugUrlRefCSValue(envVar, outputKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportSlugUrlRefCSValue(envVar, outputKey) {
|
|
||||||
core.exportVariable(outputKey, slug_1.slugurlref_cs(envVar));
|
|
||||||
}
|
|
||||||
function exportSlugUrlRef(inputKey, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
exportSlugUrlRefValue(envVar, outputKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportSlugUrlRefValue(envVar, outputKey) {
|
|
||||||
core.exportVariable(outputKey, slug_1.slugurlref(envVar));
|
|
||||||
}
|
|
||||||
function exportShortSha(inputKey, outputKey) {
|
|
||||||
const envVar = process.env[inputKey];
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, short_1.shortsha(envVar));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function exportBranchName() {
|
|
||||||
//GITHUB_HEAD_REF is only set for pull request events https://docs.github.com/en/actions/reference/environment-variables
|
|
||||||
const isPullRequest = !!process.env.GITHUB_HEAD_REF;
|
|
||||||
let refName;
|
|
||||||
if (isPullRequest) {
|
|
||||||
refName = process.env.GITHUB_HEAD_REF;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
refName = process.env.GITHUB_REF;
|
|
||||||
}
|
|
||||||
if (refName) {
|
|
||||||
core.exportVariable(GITHUB_REF_NAME, slug_1.removeRef(refName));
|
|
||||||
exportSlugRefValue(refName, GITHUB_REF_NAME_SLUG);
|
|
||||||
exportSlugRefCSValue(refName, GITHUB_REF_NAME_SLUG_CS);
|
|
||||||
exportSlugUrlRefValue(refName, GITHUB_REF_NAME_SLUG_URL);
|
|
||||||
exportSlugUrlRefCSValue(refName, GITHUB_REF_NAME_SLUG_URL_CS);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
run();
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 186:
|
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const command_1 = __webpack_require__(351);
|
|
||||||
const file_command_1 = __webpack_require__(717);
|
|
||||||
const utils_1 = __webpack_require__(278);
|
|
||||||
const os = __importStar(__webpack_require__(87));
|
|
||||||
const path = __importStar(__webpack_require__(622));
|
|
||||||
/**
|
|
||||||
* The code to exit an action
|
|
||||||
*/
|
|
||||||
var ExitCode;
|
|
||||||
(function (ExitCode) {
|
|
||||||
/**
|
|
||||||
* A code indicating that the action was successful
|
|
||||||
*/
|
|
||||||
ExitCode[ExitCode["Success"] = 0] = "Success";
|
|
||||||
/**
|
|
||||||
* A code indicating that the action was a failure
|
|
||||||
*/
|
|
||||||
ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
|
||||||
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Variables
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Sets env variable for this action and future actions in the job
|
|
||||||
* @param name the name of the variable to set
|
|
||||||
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
|
|
||||||
*/
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
function exportVariable(name, val) {
|
|
||||||
const convertedVal = utils_1.toCommandValue(val);
|
|
||||||
process.env[name] = convertedVal;
|
|
||||||
const filePath = process.env['GITHUB_ENV'] || '';
|
|
||||||
if (filePath) {
|
|
||||||
const delimiter = '_GitHubActionsFileCommandDelimeter_';
|
|
||||||
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
|
|
||||||
file_command_1.issueCommand('ENV', commandValue);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
command_1.issueCommand('set-env', { name }, convertedVal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.exportVariable = exportVariable;
|
|
||||||
/**
|
|
||||||
* Registers a secret which will get masked from logs
|
|
||||||
* @param secret value of the secret
|
|
||||||
*/
|
|
||||||
function setSecret(secret) {
|
|
||||||
command_1.issueCommand('add-mask', {}, secret);
|
|
||||||
}
|
|
||||||
exports.setSecret = setSecret;
|
|
||||||
/**
|
|
||||||
* Prepends inputPath to the PATH (for this action and future actions)
|
|
||||||
* @param inputPath
|
|
||||||
*/
|
|
||||||
function addPath(inputPath) {
|
|
||||||
const filePath = process.env['GITHUB_PATH'] || '';
|
|
||||||
if (filePath) {
|
|
||||||
file_command_1.issueCommand('PATH', inputPath);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
command_1.issueCommand('add-path', {}, inputPath);
|
|
||||||
}
|
|
||||||
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
|
||||||
}
|
|
||||||
exports.addPath = addPath;
|
|
||||||
/**
|
|
||||||
* Gets the value of an input. The value is also trimmed.
|
|
||||||
*
|
|
||||||
* @param name name of the input to get
|
|
||||||
* @param options optional. See InputOptions.
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
function getInput(name, options) {
|
|
||||||
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
|
|
||||||
if (options && options.required && !val) {
|
|
||||||
throw new Error(`Input required and not supplied: ${name}`);
|
|
||||||
}
|
|
||||||
return val.trim();
|
|
||||||
}
|
|
||||||
exports.getInput = getInput;
|
|
||||||
/**
|
|
||||||
* Sets the value of an output.
|
|
||||||
*
|
|
||||||
* @param name name of the output to set
|
|
||||||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
|
||||||
*/
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
function setOutput(name, value) {
|
|
||||||
process.stdout.write(os.EOL);
|
|
||||||
command_1.issueCommand('set-output', { name }, value);
|
|
||||||
}
|
|
||||||
exports.setOutput = setOutput;
|
|
||||||
/**
|
|
||||||
* Enables or disables the echoing of commands into stdout for the rest of the step.
|
|
||||||
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function setCommandEcho(enabled) {
|
|
||||||
command_1.issue('echo', enabled ? 'on' : 'off');
|
|
||||||
}
|
|
||||||
exports.setCommandEcho = setCommandEcho;
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Results
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Sets the action status to failed.
|
|
||||||
* When the action exits it will be with an exit code of 1
|
|
||||||
* @param message add error issue message
|
|
||||||
*/
|
|
||||||
function setFailed(message) {
|
|
||||||
process.exitCode = ExitCode.Failure;
|
|
||||||
error(message);
|
|
||||||
}
|
|
||||||
exports.setFailed = setFailed;
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Logging Commands
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Gets whether Actions Step Debug is on or not
|
|
||||||
*/
|
|
||||||
function isDebug() {
|
|
||||||
return process.env['RUNNER_DEBUG'] === '1';
|
|
||||||
}
|
|
||||||
exports.isDebug = isDebug;
|
|
||||||
/**
|
|
||||||
* Writes debug message to user log
|
|
||||||
* @param message debug message
|
|
||||||
*/
|
|
||||||
function debug(message) {
|
|
||||||
command_1.issueCommand('debug', {}, message);
|
|
||||||
}
|
|
||||||
exports.debug = debug;
|
|
||||||
/**
|
|
||||||
* Adds an error issue
|
|
||||||
* @param message error issue message. Errors will be converted to string via toString()
|
|
||||||
*/
|
|
||||||
function error(message) {
|
|
||||||
command_1.issue('error', message instanceof Error ? message.toString() : message);
|
|
||||||
}
|
|
||||||
exports.error = error;
|
|
||||||
/**
|
|
||||||
* Adds an warning issue
|
|
||||||
* @param message warning issue message. Errors will be converted to string via toString()
|
|
||||||
*/
|
|
||||||
function warning(message) {
|
|
||||||
command_1.issue('warning', message instanceof Error ? message.toString() : message);
|
|
||||||
}
|
|
||||||
exports.warning = warning;
|
|
||||||
/**
|
|
||||||
* Writes info to log with console.log.
|
|
||||||
* @param message info message
|
|
||||||
*/
|
|
||||||
function info(message) {
|
|
||||||
process.stdout.write(message + os.EOL);
|
|
||||||
}
|
|
||||||
exports.info = info;
|
|
||||||
/**
|
|
||||||
* Begin an output group.
|
|
||||||
*
|
|
||||||
* Output until the next `groupEnd` will be foldable in this group
|
|
||||||
*
|
|
||||||
* @param name The name of the output group
|
|
||||||
*/
|
|
||||||
function startGroup(name) {
|
|
||||||
command_1.issue('group', name);
|
|
||||||
}
|
|
||||||
exports.startGroup = startGroup;
|
|
||||||
/**
|
|
||||||
* End an output group.
|
|
||||||
*/
|
|
||||||
function endGroup() {
|
|
||||||
command_1.issue('endgroup');
|
|
||||||
}
|
|
||||||
exports.endGroup = endGroup;
|
|
||||||
/**
|
|
||||||
* Wrap an asynchronous function call in a group.
|
|
||||||
*
|
|
||||||
* Returns the same type as the function itself.
|
|
||||||
*
|
|
||||||
* @param name The name of the group
|
|
||||||
* @param fn The function to wrap in the group
|
|
||||||
*/
|
|
||||||
function group(name, fn) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
startGroup(name);
|
|
||||||
let result;
|
|
||||||
try {
|
|
||||||
result = yield fn();
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
endGroup();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.group = group;
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
// Wrapper action state
|
|
||||||
//-----------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* Saves state for current action, the state can only be retrieved by this action's post job execution.
|
|
||||||
*
|
|
||||||
* @param name name of the state to store
|
|
||||||
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
|
|
||||||
*/
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
function saveState(name, value) {
|
|
||||||
command_1.issueCommand('save-state', { name }, value);
|
|
||||||
}
|
|
||||||
exports.saveState = saveState;
|
|
||||||
/**
|
|
||||||
* Gets the value of an state set by this action's main execution.
|
|
||||||
*
|
|
||||||
* @param name name of the state to get
|
|
||||||
* @returns string
|
|
||||||
*/
|
|
||||||
function getState(name) {
|
|
||||||
return process.env[`STATE_${name}`] || '';
|
|
||||||
}
|
|
||||||
exports.getState = getState;
|
|
||||||
//# sourceMappingURL=core.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 213:
|
|
||||||
/***/ (function(__unusedmodule, exports) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.shortsha = void 0;
|
|
||||||
const SHORT_SHA_SIZE = 8;
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - limit the string size to 8 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
function shortsha(envVar) {
|
|
||||||
return envVar.substring(0, SHORT_SHA_SIZE);
|
|
||||||
}
|
|
||||||
exports.shortsha = shortsha;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 278:
|
|
||||||
/***/ (function(__unusedmodule, exports) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// We use any as a valid input type
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
/**
|
|
||||||
* Sanitizes an input into a string so it can be passed into issueCommand safely
|
|
||||||
* @param input input to sanitize into a string
|
|
||||||
*/
|
|
||||||
function toCommandValue(input) {
|
|
||||||
if (input === null || input === undefined) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
else if (typeof input === 'string' || input instanceof String) {
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
return JSON.stringify(input);
|
|
||||||
}
|
|
||||||
exports.toCommandValue = toCommandValue;
|
|
||||||
//# sourceMappingURL=utils.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 351:
|
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
const os = __importStar(__webpack_require__(87));
|
|
||||||
const utils_1 = __webpack_require__(278);
|
|
||||||
/**
|
|
||||||
* Commands
|
|
||||||
*
|
|
||||||
* Command Format:
|
|
||||||
* ::name key=value,key=value::message
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ::warning::This is the message
|
|
||||||
* ::set-env name=MY_VAR::some value
|
|
||||||
*/
|
|
||||||
function issueCommand(command, properties, message) {
|
|
||||||
const cmd = new Command(command, properties, message);
|
|
||||||
process.stdout.write(cmd.toString() + os.EOL);
|
|
||||||
}
|
|
||||||
exports.issueCommand = issueCommand;
|
|
||||||
function issue(name, message = '') {
|
|
||||||
issueCommand(name, {}, message);
|
|
||||||
}
|
|
||||||
exports.issue = issue;
|
|
||||||
const CMD_STRING = '::';
|
|
||||||
class Command {
|
|
||||||
constructor(command, properties, message) {
|
|
||||||
if (!command) {
|
|
||||||
command = 'missing.command';
|
|
||||||
}
|
|
||||||
this.command = command;
|
|
||||||
this.properties = properties;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
toString() {
|
|
||||||
let cmdStr = CMD_STRING + this.command;
|
|
||||||
if (this.properties && Object.keys(this.properties).length > 0) {
|
|
||||||
cmdStr += ' ';
|
|
||||||
let first = true;
|
|
||||||
for (const key in this.properties) {
|
|
||||||
if (this.properties.hasOwnProperty(key)) {
|
|
||||||
const val = this.properties[key];
|
|
||||||
if (val) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cmdStr += ',';
|
|
||||||
}
|
|
||||||
cmdStr += `${key}=${escapeProperty(val)}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
|
|
||||||
return cmdStr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function escapeData(s) {
|
|
||||||
return utils_1.toCommandValue(s)
|
|
||||||
.replace(/%/g, '%25')
|
|
||||||
.replace(/\r/g, '%0D')
|
|
||||||
.replace(/\n/g, '%0A');
|
|
||||||
}
|
|
||||||
function escapeProperty(s) {
|
|
||||||
return utils_1.toCommandValue(s)
|
|
||||||
.replace(/%/g, '%25')
|
|
||||||
.replace(/\r/g, '%0D')
|
|
||||||
.replace(/\n/g, '%0A')
|
|
||||||
.replace(/:/g, '%3A')
|
|
||||||
.replace(/,/g, '%2C');
|
|
||||||
}
|
|
||||||
//# sourceMappingURL=command.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 373:
|
|
||||||
/***/ (function(__unusedmodule, exports) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.get_second_part = exports.get_first_part = void 0;
|
|
||||||
/**
|
|
||||||
* Get the first part of envVar
|
|
||||||
* @param envVar to be split
|
|
||||||
* @param separator of the split
|
|
||||||
*/
|
|
||||||
function get_first_part(envVar, separator) {
|
|
||||||
return envVar.replace(RegExp(`${separator}.*$`), '');
|
|
||||||
}
|
|
||||||
exports.get_first_part = get_first_part;
|
|
||||||
/**
|
|
||||||
* Get the second part of envVar
|
|
||||||
* @param envVar to be split
|
|
||||||
* @param separator of the split
|
|
||||||
*/
|
|
||||||
function get_second_part(envVar, separator) {
|
|
||||||
return envVar.replace(RegExp(`^.*${separator}`), '');
|
|
||||||
}
|
|
||||||
exports.get_second_part = get_second_part;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 565:
|
|
||||||
/***/ (function(__unusedmodule, exports) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.removeRef = 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
|
|
||||||
* - 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(envVar) {
|
|
||||||
return slug_cs(envVar.toLowerCase());
|
|
||||||
}
|
|
||||||
exports.slug = slug;
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
function slugref(envVar) {
|
|
||||||
return slugref_cs(envVar.toLowerCase());
|
|
||||||
}
|
|
||||||
exports.slugref = slugref;
|
|
||||||
/**
|
|
||||||
* 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(replaceAnyNonUrlCharactersWithHyphen(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
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
function slugurl(envVar) {
|
|
||||||
return slug(replaceAnyNonUrlCharactersWithHyphen(envVar));
|
|
||||||
}
|
|
||||||
exports.slugurl = slugurl;
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
function slugurlref(envVar) {
|
|
||||||
return slugurl(slugref(envVar));
|
|
||||||
}
|
|
||||||
exports.slugurlref = slugurlref;
|
|
||||||
function trailHyphen(envVar) {
|
|
||||||
return envVar.replace(RegExp('^-*', 'g'), '').replace(RegExp('-*$', 'g'), '');
|
|
||||||
}
|
|
||||||
function replaceAnyNonAlphanumericCharacter(envVar) {
|
|
||||||
return envVar.replace(RegExp('[^a-zA-Z0-9._]', 'g'), '-');
|
|
||||||
}
|
|
||||||
function replaceAnyNonUrlCharactersWithHyphen(envVar) {
|
|
||||||
return envVar.replace(RegExp('[._]', 'g'), '-');
|
|
||||||
}
|
|
||||||
function removeRef(envVar) {
|
|
||||||
return envVar.replace(RegExp('^refs/(heads|tags|pull)/'), '');
|
|
||||||
}
|
|
||||||
exports.removeRef = removeRef;
|
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 622:
|
|
||||||
/***/ (function(module) {
|
|
||||||
|
|
||||||
module.exports = require("path");
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 717:
|
|
||||||
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
// For internal use, subject to change.
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
// We use any as a valid input type
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
const fs = __importStar(__webpack_require__(747));
|
|
||||||
const os = __importStar(__webpack_require__(87));
|
|
||||||
const utils_1 = __webpack_require__(278);
|
|
||||||
function issueCommand(command, message) {
|
|
||||||
const filePath = process.env[`GITHUB_${command}`];
|
|
||||||
if (!filePath) {
|
|
||||||
throw new Error(`Unable to find environment variable for file command ${command}`);
|
|
||||||
}
|
|
||||||
if (!fs.existsSync(filePath)) {
|
|
||||||
throw new Error(`Missing file at path: ${filePath}`);
|
|
||||||
}
|
|
||||||
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
|
|
||||||
encoding: 'utf8'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.issueCommand = issueCommand;
|
|
||||||
//# sourceMappingURL=file-command.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 747:
|
|
||||||
/***/ (function(module) {
|
|
||||||
|
|
||||||
module.exports = require("fs");
|
|
||||||
|
|
||||||
/***/ })
|
|
||||||
|
|
||||||
/******/ });
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
||||||
1
dist/index.js.map
vendored
1
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
3912
dist/sourcemap-register.js
vendored
3912
dist/sourcemap-register.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
clearMocks: true,
|
|
||||||
moduleFileExtensions: ['js', 'ts'],
|
|
||||||
testEnvironment: 'node',
|
|
||||||
testMatch: ['**/*.test.ts'],
|
|
||||||
testRunner: 'jest-circus/runner',
|
|
||||||
transform: {
|
|
||||||
'^.+\\.ts$': 'ts-jest'
|
|
||||||
},
|
|
||||||
verbose: true
|
|
||||||
}
|
|
||||||
10089
package-lock.json
generated
10089
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
48
package.json
48
package.json
@@ -1,48 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "github-slug-action",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"license": "MIT",
|
|
||||||
"private": true,
|
|
||||||
"description": "Github slug action",
|
|
||||||
"main": "lib/main.js",
|
|
||||||
"scripts": {
|
|
||||||
"build": "tsc",
|
|
||||||
"format": "prettier --write **/*.ts",
|
|
||||||
"format-check": "prettier --check **/*.ts",
|
|
||||||
"lint": "eslint src/**/*.ts",
|
|
||||||
"package": "ncc build --source-map",
|
|
||||||
"test": "jest",
|
|
||||||
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "http://github.com/rlespinasse/github-slug-action.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"actions",
|
|
||||||
"node",
|
|
||||||
"setup"
|
|
||||||
],
|
|
||||||
"author": "rlespinasse",
|
|
||||||
"dependencies": {
|
|
||||||
"@actions/core": "^1.2.6"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/jest": "^26.0.20",
|
|
||||||
"@types/node": "^14.14.21",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
|
||||||
"@vercel/ncc": "^0.23.0",
|
|
||||||
"eslint": "^7.18.0",
|
|
||||||
"eslint-plugin-github": "^4.1.1",
|
|
||||||
"eslint-plugin-jest": "^23.20.0",
|
|
||||||
"jest": "^26.6.3",
|
|
||||||
"jest-circus": "^26.6.3",
|
|
||||||
"js-yaml": "^3.14.1",
|
|
||||||
"prettier": "^2.2.1",
|
|
||||||
"ts-jest": "^26.4.4",
|
|
||||||
"typescript": "^3.9.7"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"/dist"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
401
src/main.ts
401
src/main.ts
@@ -1,401 +0,0 @@
|
|||||||
import * as core from '@actions/core'
|
|
||||||
import {
|
|
||||||
removeRef,
|
|
||||||
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'
|
|
||||||
|
|
||||||
const SEPARATOR = '/'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Inputs environments variables keys from Github actions job
|
|
||||||
* see https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
|
||||||
*/
|
|
||||||
const GITHUB_REPOSITORY = 'GITHUB_REPOSITORY'
|
|
||||||
const GITHUB_REF = 'GITHUB_REF'
|
|
||||||
const GITHUB_HEAD_REF = 'GITHUB_HEAD_REF'
|
|
||||||
const GITHUB_BASE_REF = 'GITHUB_BASE_REF'
|
|
||||||
const GITHUB_SHA = 'GITHUB_SHA'
|
|
||||||
const GITHUB_EVENT_PATH = 'GITHUB_EVENT_PATH'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Partial outputs environments variables keys
|
|
||||||
*/
|
|
||||||
const GITHUB_REPOSITORY_OWNER_PART = 'GITHUB_REPOSITORY_OWNER_PART'
|
|
||||||
const GITHUB_REPOSITORY_NAME_PART = 'GITHUB_REPOSITORY_NAME_PART'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* New environments variables keys
|
|
||||||
*/
|
|
||||||
const GITHUB_REF_NAME = 'GITHUB_REF_NAME'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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'
|
|
||||||
const GITHUB_REF_NAME_SLUG = 'GITHUB_REF_NAME_SLUG'
|
|
||||||
const GITHUB_REF_NAME_SLUG_CS = 'GITHUB_REF_NAME_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'
|
|
||||||
const GITHUB_REF_NAME_SLUG_URL = 'GITHUB_REF_NAME_SLUG_URL'
|
|
||||||
const GITHUB_REF_NAME_SLUG_URL_CS = 'GITHUB_REF_NAME_SLUG_URL_CS'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shorted outputs environments variables keys
|
|
||||||
*/
|
|
||||||
const GITHUB_SHA_SHORT = 'GITHUB_SHA_SHORT'
|
|
||||||
const GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT =
|
|
||||||
'GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT'
|
|
||||||
|
|
||||||
async function run(): Promise<void> {
|
|
||||||
try {
|
|
||||||
const eventPath = process.env[GITHUB_EVENT_PATH]
|
|
||||||
if (eventPath) {
|
|
||||||
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,
|
|
||||||
shortsha(eventData.pull_request.head.sha)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
exportBranchName()
|
|
||||||
} catch (error) {
|
|
||||||
core.setFailed(error.message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportFirstPart(
|
|
||||||
inputKey: string,
|
|
||||||
separator: string,
|
|
||||||
outputKey: string
|
|
||||||
): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, get_first_part(envVar, separator))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSecondPart(
|
|
||||||
inputKey: string,
|
|
||||||
separator: string,
|
|
||||||
outputKey: string
|
|
||||||
): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, get_second_part(envVar, separator))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
|
||||||
core.exportVariable(outputKey, slug(envVar))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|
||||||
outputKey: string
|
|
||||||
): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
const value = get_first_part(envVar, separator)
|
|
||||||
core.exportVariable(outputKey, slug(value))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|
||||||
outputKey: string
|
|
||||||
): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
const value = get_second_part(envVar, separator)
|
|
||||||
core.exportVariable(outputKey, slug(value))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlugRefCS(inputKey: string, outputKey: string): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
exportSlugRefCSValue(envVar, outputKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlugRefCSValue(envVar: string, outputKey: string): void {
|
|
||||||
core.exportVariable(outputKey, slugref_cs(envVar))
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlugRef(inputKey: string, outputKey: string): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
exportSlugRefValue(envVar, outputKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlugRefValue(envVar: string, outputKey: string): void {
|
|
||||||
core.exportVariable(outputKey, slugref(envVar))
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
|
||||||
core.exportVariable(outputKey, slugurl(envVar))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|
||||||
outputKey: string
|
|
||||||
): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
const value = get_first_part(envVar, separator)
|
|
||||||
core.exportVariable(outputKey, slugurl(value))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|
||||||
outputKey: string
|
|
||||||
): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
const value = get_second_part(envVar, separator)
|
|
||||||
core.exportVariable(outputKey, slugurl(value))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlugUrlRefCS(inputKey: string, outputKey: string): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
exportSlugUrlRefCSValue(envVar, outputKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlugUrlRefCSValue(envVar: string, outputKey: string): void {
|
|
||||||
core.exportVariable(outputKey, slugurlref_cs(envVar))
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlugUrlRef(inputKey: string, outputKey: string): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
exportSlugUrlRefValue(envVar, outputKey)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportSlugUrlRefValue(envVar: string, outputKey: string): void {
|
|
||||||
core.exportVariable(outputKey, slugurlref(envVar))
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportShortSha(inputKey: string, outputKey: string): void {
|
|
||||||
const envVar = process.env[inputKey]
|
|
||||||
if (envVar) {
|
|
||||||
core.exportVariable(outputKey, shortsha(envVar))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportBranchName(): void {
|
|
||||||
//GITHUB_HEAD_REF is only set for pull request events https://docs.github.com/en/actions/reference/environment-variables
|
|
||||||
const isPullRequest = !!process.env.GITHUB_HEAD_REF
|
|
||||||
let refName
|
|
||||||
if (isPullRequest) {
|
|
||||||
refName = process.env.GITHUB_HEAD_REF
|
|
||||||
} else {
|
|
||||||
refName = process.env.GITHUB_REF
|
|
||||||
}
|
|
||||||
if (refName) {
|
|
||||||
core.exportVariable(GITHUB_REF_NAME, removeRef(refName))
|
|
||||||
exportSlugRefValue(refName, GITHUB_REF_NAME_SLUG)
|
|
||||||
exportSlugRefCSValue(refName, GITHUB_REF_NAME_SLUG_CS)
|
|
||||||
exportSlugUrlRefValue(refName, GITHUB_REF_NAME_SLUG_URL)
|
|
||||||
exportSlugUrlRefCSValue(refName, GITHUB_REF_NAME_SLUG_URL_CS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
run()
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* Get the first part of envVar
|
|
||||||
* @param envVar to be split
|
|
||||||
* @param separator of the split
|
|
||||||
*/
|
|
||||||
export function get_first_part(envVar: string, separator: string): string {
|
|
||||||
return envVar.replace(RegExp(`${separator}.*$`), '')
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the second part of envVar
|
|
||||||
* @param envVar to be split
|
|
||||||
* @param separator of the split
|
|
||||||
*/
|
|
||||||
export function get_second_part(envVar: string, separator: string): string {
|
|
||||||
return envVar.replace(RegExp(`^.*${separator}`), '')
|
|
||||||
}
|
|
||||||
10
src/short.ts
10
src/short.ts
@@ -1,10 +0,0 @@
|
|||||||
const SHORT_SHA_SIZE = 8
|
|
||||||
|
|
||||||
/**
|
|
||||||
* slug will take envVar and then :
|
|
||||||
* - limit the string size to 8 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
export function shortsha(envVar: string): string {
|
|
||||||
return envVar.substring(0, SHORT_SHA_SIZE)
|
|
||||||
}
|
|
||||||
116
src/slug.ts
116
src/slug.ts
@@ -1,116 +0,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
|
|
||||||
*/
|
|
||||||
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
|
|
||||||
* - 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(envVar: string): string {
|
|
||||||
return slug_cs(envVar.toLowerCase())
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
export function slugref(envVar: string): string {
|
|
||||||
return slugref_cs(envVar.toLowerCase())
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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(replaceAnyNonUrlCharactersWithHyphen(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
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
export function slugurl(envVar: string): string {
|
|
||||||
return slug(replaceAnyNonUrlCharactersWithHyphen(envVar))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* - limit the string size to 63 characters
|
|
||||||
* @param envVar to be slugged
|
|
||||||
*/
|
|
||||||
export function slugurlref(envVar: string): string {
|
|
||||||
return slugurl(slugref(envVar))
|
|
||||||
}
|
|
||||||
|
|
||||||
function trailHyphen(envVar: string): string {
|
|
||||||
return envVar.replace(RegExp('^-*', 'g'), '').replace(RegExp('-*$', 'g'), '')
|
|
||||||
}
|
|
||||||
|
|
||||||
function replaceAnyNonAlphanumericCharacter(envVar: string): string {
|
|
||||||
return envVar.replace(RegExp('[^a-zA-Z0-9._]', 'g'), '-')
|
|
||||||
}
|
|
||||||
|
|
||||||
function replaceAnyNonUrlCharactersWithHyphen(envVar: string): string {
|
|
||||||
return envVar.replace(RegExp('[._]', 'g'), '-')
|
|
||||||
}
|
|
||||||
|
|
||||||
export function removeRef(envVar: string): string {
|
|
||||||
return envVar.replace(RegExp('^refs/(heads|tags|pull)/'), '')
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
|
||||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
|
||||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
||||||
"strict": true, /* Enable all strict type-checking options. */
|
|
||||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
||||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
||||||
},
|
|
||||||
"exclude": ["node_modules", "**/*.test.ts"]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user