mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-06-10 16:43:09 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ebfc49c0e9 | ||
|
|
68babf69b3 | ||
|
|
1bf76b7bc6 | ||
|
|
46a738e36b | ||
|
|
82da1fd43c | ||
|
|
99afdf4551 | ||
|
|
944fee4603 | ||
|
|
19f9c84ac6 | ||
|
|
596b602d8a | ||
|
|
b98d94bda3 | ||
|
|
e8c1f6060b | ||
|
|
f80aa0fae4 |
8
.github/workflows/codeql-analysis.yml
vendored
8
.github/workflows/codeql-analysis.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: CodeQL
|
name: '[v3] CodeQL'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -8,7 +8,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- v3.x
|
- v3.x
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 6 * * 1"
|
- cron: '0 6 * * 1'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
analyse:
|
analyse:
|
||||||
@@ -17,10 +17,10 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
language: ["javascript"]
|
language: ['javascript']
|
||||||
steps:
|
steps:
|
||||||
- uses: technote-space/auto-cancel-redundant-workflow@v1
|
- uses: technote-space/auto-cancel-redundant-workflow@v1
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: github/codeql-action/init@v1
|
- uses: github/codeql-action/init@v1
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
|
|||||||
4
.github/workflows/github-slug.yml
vendored
4
.github/workflows/github-slug.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Github Slug testing
|
name: '[v3] Testing'
|
||||||
on: [push]
|
on: [push]
|
||||||
jobs:
|
jobs:
|
||||||
github-slug-on-os:
|
github-slug-on-os:
|
||||||
@@ -9,7 +9,7 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm run all
|
- run: npm run all
|
||||||
- uses: ./
|
- uses: ./
|
||||||
|
|||||||
31
.github/workflows/linter.yml
vendored
31
.github/workflows/linter.yml
vendored
@@ -1,31 +0,0 @@
|
|||||||
name: Lint
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- v3.x
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- v3.x
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
name: Lint
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: technote-space/auto-cancel-redundant-workflow@v1
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- uses: github/super-linter@v3
|
|
||||||
env:
|
|
||||||
VALIDATE_ALL_CODEBASE: false
|
|
||||||
VALIDATE_JAVASCRIPT_STANDARD: false
|
|
||||||
VALIDATE_TYPESCRIPT_STANDARD: false
|
|
||||||
LINTER_RULES_PATH: .
|
|
||||||
JAVASCRIPT_ES_CONFIG_FILE: .eslintrc.json
|
|
||||||
JAVASCRIPT_DEFAULT_STYLE: prettier
|
|
||||||
DEFAULT_BRANCH: v3.x
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
FILTER_REGEX_INCLUDE: .*src/.*
|
|
||||||
6
.github/workflows/release-dryrun.yml
vendored
6
.github/workflows/release-dryrun.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Release DryRun
|
name: '[v3] Release DryRun'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -10,11 +10,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: technote-space/auto-cancel-redundant-workflow@v1
|
- uses: technote-space/auto-cancel-redundant-workflow@v1
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm run all
|
- run: npm run all
|
||||||
- uses: ./
|
- uses: ./
|
||||||
- uses: cycjimmy/semantic-release-action@v2
|
- uses: cycjimmy/semantic-release-action@v3
|
||||||
with:
|
with:
|
||||||
branches: |
|
branches: |
|
||||||
[
|
[
|
||||||
|
|||||||
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Release
|
name: '[v3] Release'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -10,9 +10,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: technote-space/auto-cancel-redundant-workflow@v1
|
- uses: technote-space/auto-cancel-redundant-workflow@v1
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- run: npm install
|
- run: npm install
|
||||||
- run: npm run all
|
- run: npm run all
|
||||||
- uses: cycjimmy/semantic-release-action@v2
|
- uses: cycjimmy/semantic-release-action@v3
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|||||||
14
CHANGELOG.md
14
CHANGELOG.md
@@ -1,3 +1,17 @@
|
|||||||
|
# [3.7.0](https://github.com/rlespinasse/github-slug-action/compare/v3.6.1...v3.7.0) (2022-10-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* generate proper git tag ([68babf6](https://github.com/rlespinasse/github-slug-action/commit/68babf69b34f4c4b556ea350616c5408d627937e))
|
||||||
|
|
||||||
|
## [3.6.1](https://github.com/rlespinasse/github-slug-action/compare/3.6.0...3.6.1) (2022-08-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* remove trailing hyphens if any after cut ([19f9c84](https://github.com/rlespinasse/github-slug-action/commit/19f9c84ac61b17071a3cfc4ae984ac0e2ba1cdae))
|
||||||
|
|
||||||
# [3.6.0](http://github.com/rlespinasse/github-slug-action/compare/3.5.1...3.6.0) (2021-09-15)
|
# [3.6.0](http://github.com/rlespinasse/github-slug-action/compare/3.5.1...3.6.0) (2021-09-15)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
64
README.md
64
README.md
@@ -4,7 +4,7 @@
|
|||||||
![Lint][lint-badge]
|
![Lint][lint-badge]
|
||||||
[![Licence][license-badge]][license]
|
[![Licence][license-badge]][license]
|
||||||
|
|
||||||
This GitHub Action will expose the slug/short values of [some GitHub environment variables][github-env-vars] inside your GitHub workflow.
|
This GitHub Action will expose the slug/short values of [some GitHub environment variables][default-environment-variables] inside your GitHub workflow.
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
@@ -21,6 +21,8 @@ This GitHub Action will expose the slug/short values of [some GitHub environment
|
|||||||
- [Contribute](#contribute)
|
- [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)
|
||||||
|
- [Known environment variable conflicts](#known-environment-variable-conflicts)
|
||||||
|
- [GITHUB_REF_NAME](#github_ref_name)
|
||||||
- [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)
|
||||||
- [Thanks for talking about us](#thanks-for-talking-about-us)
|
- [Thanks for talking about us](#thanks-for-talking-about-us)
|
||||||
|
|
||||||
@@ -30,8 +32,9 @@ This GitHub Action will expose the slug/short values of [some GitHub environment
|
|||||||
|
|
||||||
- put the variable content in lower case
|
- put the variable content in lower case
|
||||||
- replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
- replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
||||||
- remove leading and trailing `-` character
|
- remove leading `-` characters
|
||||||
- limit the string size to 63 characters
|
- limit the string size to 63 characters
|
||||||
|
- remove trailing `-` characters
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Others <b>Slug-ish</b> commands are available</summary>
|
<summary>Others <b>Slug-ish</b> commands are available</summary>
|
||||||
@@ -126,34 +129,42 @@ Follow [Developers guide](DEVELOPERS.md)
|
|||||||
|
|
||||||
### One of the environment variables doesn't work as intended
|
### One of the environment variables doesn't work as intended
|
||||||
|
|
||||||
[**Note**][naming-conventions]: GitHub reserves the `GITHUB_` environment variable prefix for internal use by GitHub. Setting an environment variable or secret with the `GITHUB_` prefix will result in an error.
|
[**Note**][naming-conventions]: When you set a custom environment variable, you cannot use any of the default environment variable names. For a complete list of these, see [Default environment variables][default-environment-variables]. **If you attempt to override the value of one of these default environment variables, the assignment is ignored.**
|
||||||
|
|
||||||
Currently, a GitHub workflow setting a `GITHUB_` variable will not cause an error, it will just fail silently.
|
If a variable start to be used as default environment variable, the environment variable may have a different behavior than the expected one.
|
||||||
And if a custom `GITHUB_` variable is in conflict with an official `GITHUB_` variable, the offical `GITHUB_` variable will override custom one.
|
|
||||||
|
|
||||||
<details>
|
If this append, the `${{ env.GITHUB_AWESOME_VARIABLE }}` and `$GITHUB_AWESOME_VARIABLE` expression will not works in the same way.
|
||||||
<summary>Test workflow</summary>
|
|
||||||
<p>
|
- `${{ env.GITHUB_AWESOME_VARIABLE }}` will serve the behavior of this action,
|
||||||
|
- `$GITHUB_AWESOME_VARIABLE` will serve the behavior of GitHub Action.
|
||||||
|
|
||||||
|
Otherwise the two expression will serve the behavior of this action.
|
||||||
|
This will not occurs if you use the `prefix` input to avoid the issue.
|
||||||
|
|
||||||
|
**NOTE:** If detected, the maintainers of this action will choose the best course of action depending of the impact.
|
||||||
|
|
||||||
|
#### Known environment variable conflicts
|
||||||
|
|
||||||
|
##### GITHUB_REF_NAME
|
||||||
|
|
||||||
|
The behavior is the same as the GitHub one except on `pull_request*` workflows ([Ready the full story][issue-104]).
|
||||||
|
|
||||||
|
- `${{ env.GITHUB_REF_NAME }}` will serve the behavior of this action,
|
||||||
|
- `$GITHUB_REF_NAME` will serve the behavior of GitHub Action.
|
||||||
|
|
||||||
|
On `pull_request*` workflows, the content will be `<PR-number>/merge` instead of the branch name.
|
||||||
|
|
||||||
|
A possible workaround is to use `prefix` input available in `v4` version
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: Test
|
- name: Inject slug/short variables
|
||||||
on: push
|
uses: rlespinasse/github-slug-action@v4
|
||||||
jobs:
|
with:
|
||||||
build:
|
prefix: CI_
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- run: echo ${GITHUB_REF}
|
|
||||||
# print "refs/heads/v3.x"
|
|
||||||
- run: echo "GITHUB_REF=one_value" >> "$GITHUB_ENV"
|
|
||||||
- run: echo ${GITHUB_REF}
|
|
||||||
# print "refs/heads/v3.x"
|
|
||||||
- run: echo "GITHUB_REF_SLUG=another_value" >> "$GITHUB_ENV"
|
|
||||||
- run: echo ${GITHUB_REF_SLUG}
|
|
||||||
# print "another_value"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</p>
|
Then `${{ env.CI_GITHUB_REF_NAME }}`, and `$CI_GITHUB_REF_NAME` will serve the behavior of this action.
|
||||||
</details>
|
And `$GITHUB_REF_NAME` will serve the behavior of GitHub Action.
|
||||||
|
|
||||||
### An action could not be found at the URI
|
### An action could not be found at the URI
|
||||||
|
|
||||||
@@ -187,9 +198,10 @@ Please, use the current branch `v3.x` or a version tag (see [releases pages][rel
|
|||||||
[custom-variable]: https://github.com/rlespinasse/github-slug-action/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=
|
[custom-variable]: https://github.com/rlespinasse/github-slug-action/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=
|
||||||
[releases]: https://github.com/rlespinasse/github-slug-action/releases
|
[releases]: https://github.com/rlespinasse/github-slug-action/releases
|
||||||
[issue-15]: https://github.com/rlespinasse/github-slug-action/issues/15
|
[issue-15]: https://github.com/rlespinasse/github-slug-action/issues/15
|
||||||
|
[issue-104]: https://github.com/rlespinasse/github-slug-action/issues/104
|
||||||
|
|
||||||
[github-env-vars]: https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
|
[default-environment-variables]: https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
||||||
[dependabot]: https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot
|
[dependabot]: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
|
||||||
[webhooks-and-events]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads
|
[webhooks-and-events]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads
|
||||||
[naming-conventions]: https://docs.github.com/en/actions/reference/environment-variables#naming-conventions-for-environment-variables
|
[naming-conventions]: https://docs.github.com/en/actions/reference/environment-variables#naming-conventions-for-environment-variables
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ test('slug: a number', () => {
|
|||||||
test_slug_cs('4.2', '4.2')
|
test_slug_cs('4.2', '4.2')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('slug: an underscore', () => {
|
||||||
|
test_slug('An_Underscore', 'an_underscore')
|
||||||
|
test_slug_cs('An_Underscore', 'An_Underscore')
|
||||||
|
})
|
||||||
|
|
||||||
test('slug: special character', () => {
|
test('slug: special character', () => {
|
||||||
test_slug('feat-(!è§-character', 'feat------character')
|
test_slug('feat-(!è§-character', 'feat------character')
|
||||||
test_slug_cs('feat-(!è§-character', 'feat------character')
|
test_slug_cs('feat-(!è§-character', 'feat------character')
|
||||||
@@ -47,22 +52,22 @@ test('slug: trailing', () => {
|
|||||||
|
|
||||||
test('slug: a very long string', () => {
|
test('slug: a very long string', () => {
|
||||||
test_slug(
|
test_slug(
|
||||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||||
)
|
)
|
||||||
test_slug_cs(
|
test_slug_cs(
|
||||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-more'
|
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('slug: short string after trailing', () => {
|
test('slug: short string after trailing', () => {
|
||||||
test_slug(
|
test_slug(
|
||||||
'-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters-',
|
'-has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters-',
|
||||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||||
)
|
)
|
||||||
test_slug_cs(
|
test_slug_cs(
|
||||||
'-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters-',
|
'-has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters-',
|
||||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-more'
|
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ test('slug_ref: a fix branch', () => {
|
|||||||
test_slugref_cs('refs/heads/fix/issue_number', 'fix-issue_number')
|
test_slugref_cs('refs/heads/fix/issue_number', 'fix-issue_number')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('slug_ref: an underscore', () => {
|
||||||
|
test_slugref('refs/heads/An_Underscore', 'an_underscore')
|
||||||
|
test_slugref_cs('refs/heads/An_Underscore', 'An_Underscore')
|
||||||
|
})
|
||||||
|
|
||||||
test('slug_ref: a simple tag', () => {
|
test('slug_ref: a simple tag', () => {
|
||||||
test_slugref('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_slugref_cs('refs/tags/v1.0.0', 'v1.0.0')
|
||||||
@@ -52,12 +57,12 @@ test('slug_ref: test refs inside string', () => {
|
|||||||
|
|
||||||
test('slug_ref: a very long name', () => {
|
test('slug_ref: a very long name', () => {
|
||||||
test_slugref(
|
test_slugref(
|
||||||
'refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||||
)
|
)
|
||||||
test_slugref_cs(
|
test_slugref_cs(
|
||||||
'refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-more'
|
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ test('slug_url: a number', () => {
|
|||||||
test_slugurl_cs('4.2', '4-2')
|
test_slugurl_cs('4.2', '4-2')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('slug_url: an underscore', () => {
|
||||||
|
test_slugurl('An_Underscore', 'an-underscore')
|
||||||
|
test_slugurl_cs('An_Underscore', 'An-Underscore')
|
||||||
|
})
|
||||||
|
|
||||||
test('slug_url: trailing', () => {
|
test('slug_url: trailing', () => {
|
||||||
test_slugurl('.path.to.', 'path-to')
|
test_slugurl('.path.to.', 'path-to')
|
||||||
test_slugurl_cs('.path.to.', 'path-to')
|
test_slugurl_cs('.path.to.', 'path-to')
|
||||||
@@ -42,11 +47,11 @@ test('slug_url: trailing', () => {
|
|||||||
|
|
||||||
test('slug_url: a very long string', () => {
|
test('slug_url: a very long string', () => {
|
||||||
test_slugurl(
|
test_slugurl(
|
||||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||||
)
|
)
|
||||||
test_slugurl_cs(
|
test_slugurl_cs(
|
||||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-more'
|
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ test('slug_url_ref: a fix branch', () => {
|
|||||||
test_slugurlref_cs('refs/heads/fix/issue_number', 'fix-issue-number')
|
test_slugurlref_cs('refs/heads/fix/issue_number', 'fix-issue-number')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('slug_url_ref: an underscore', () => {
|
||||||
|
test_slugurlref('refs/heads/An_Underscore', 'an-underscore')
|
||||||
|
test_slugurlref_cs('refs/heads/An_Underscore', 'An-Underscore')
|
||||||
|
})
|
||||||
|
|
||||||
test('slug_url_ref: a simple tag', () => {
|
test('slug_url_ref: a simple tag', () => {
|
||||||
test_slugurlref('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_slugurlref_cs('refs/tags/v1.0.0', 'v1-0-0')
|
||||||
@@ -42,12 +47,12 @@ test('slug_url_ref: a reference with upper case letters', () => {
|
|||||||
|
|
||||||
test('slug_url_ref: a very long name', () => {
|
test('slug_url_ref: a very long name', () => {
|
||||||
test_slugurlref(
|
test_slugurlref(
|
||||||
'refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||||
'an-awesome-feature-very-very-very-very-very-very-very-long-more'
|
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||||
)
|
)
|
||||||
test_slugurlref_cs(
|
test_slugurlref_cs(
|
||||||
'refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||||
'an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-more'
|
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
2521
dist/index.js
vendored
2521
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
18677
package-lock.json
generated
18677
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
31
package.json
31
package.json
@@ -17,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "http://github.com/rlespinasse/github-slug-action.git"
|
"url": "https://github.com/rlespinasse/github-slug-action.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"actions",
|
"actions",
|
||||||
@@ -26,32 +26,32 @@
|
|||||||
],
|
],
|
||||||
"author": "rlespinasse",
|
"author": "rlespinasse",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.6"
|
"@actions/core": "^1.9.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@semantic-release/changelog": "^5.0.1",
|
"@semantic-release/changelog": "^6.0.1",
|
||||||
"@semantic-release/exec": "^5.0.0",
|
"@semantic-release/exec": "^6.0.0",
|
||||||
"@semantic-release/git": "^9.0.0",
|
"@semantic-release/git": "^10.0.1",
|
||||||
"@types/jest": "^26.0.20",
|
"@types/jest": "^26.0.24",
|
||||||
"@types/node": "^14.14.21",
|
"@types/node": "^14.18.25",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.22.0",
|
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
||||||
"@vercel/ncc": "^0.23.0",
|
"@vercel/ncc": "^0.23.0",
|
||||||
"eslint": "^7.18.0",
|
"eslint": "^8.0.1",
|
||||||
"eslint-plugin-github": "^4.1.1",
|
"eslint-plugin-github": "^4.3.7",
|
||||||
"eslint-plugin-jest": "^23.20.0",
|
"eslint-plugin-jest": "^23.20.0",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"jest-circus": "^26.6.3",
|
"jest-circus": "^26.6.3",
|
||||||
"js-yaml": "^3.14.1",
|
"js-yaml": "^3.14.1",
|
||||||
"prettier": "^2.2.1",
|
"prettier": "^2.7.1",
|
||||||
"semantic-release": "^17.4.0",
|
"semantic-release": "^19.0.3",
|
||||||
"ts-jest": "^26.4.4",
|
"ts-jest": "^26.5.6",
|
||||||
"typescript": "^3.9.7"
|
"typescript": "^4.2.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"/dist"
|
"/dist"
|
||||||
],
|
],
|
||||||
"release": {
|
"release": {
|
||||||
"tagFormat": "${version}",
|
"tagFormat": "v${version}",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"@semantic-release/commit-analyzer",
|
"@semantic-release/commit-analyzer",
|
||||||
"@semantic-release/release-notes-generator",
|
"@semantic-release/release-notes-generator",
|
||||||
@@ -66,7 +66,6 @@
|
|||||||
"@semantic-release/github"
|
"@semantic-release/github"
|
||||||
],
|
],
|
||||||
"branches": [
|
"branches": [
|
||||||
"v2.x",
|
|
||||||
"v3.x"
|
"v3.x"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ async function run(): Promise<void> {
|
|||||||
|
|
||||||
exportBranchName()
|
exportBranchName()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
if (error instanceof Error) core.setFailed(error.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
45
src/slug.ts
45
src/slug.ts
@@ -3,14 +3,17 @@ const MAX_SLUG_STRING_SIZE = 63
|
|||||||
/**
|
/**
|
||||||
* slug_cs will take envVar and then :
|
* slug_cs will take envVar and then :
|
||||||
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
||||||
* - remove leading and trailing `-` character
|
* - remove leading `-` characters
|
||||||
* - limit the string size to 63 characters
|
* - limit the string size to 63 characters
|
||||||
|
* - remove trailing `-` characters
|
||||||
* @param envVar to be slugged
|
* @param envVar to be slugged
|
||||||
*/
|
*/
|
||||||
export function slug_cs(envVar: string): string {
|
export function slug_cs(envVar: string): string {
|
||||||
return trailHyphen(replaceAnyNonAlphanumericCharacter(envVar)).substring(
|
return removeTrailingHyphens(
|
||||||
0,
|
removeLeadingHyphens(replaceAnyNonAlphanumericCharacter(envVar)).substring(
|
||||||
MAX_SLUG_STRING_SIZE
|
0,
|
||||||
|
MAX_SLUG_STRING_SIZE
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,8 +21,9 @@ export function slug_cs(envVar: string): string {
|
|||||||
* slug will take envVar and then :
|
* slug will take envVar and then :
|
||||||
* - put the variable content in lower case
|
* - put the variable content in lower case
|
||||||
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
||||||
* - remove leading and trailing `-` character
|
* - remove leading `-` characters
|
||||||
* - limit the string size to 63 characters
|
* - limit the string size to 63 characters
|
||||||
|
* - remove trailing `-` characters
|
||||||
* @param envVar to be slugged
|
* @param envVar to be slugged
|
||||||
*/
|
*/
|
||||||
export function slug(envVar: string): string {
|
export function slug(envVar: string): string {
|
||||||
@@ -30,8 +34,9 @@ export function slug(envVar: string): string {
|
|||||||
* slugref_cs will take envVar and then :
|
* slugref_cs will take envVar and then :
|
||||||
* - remove refs/(heads|tags|pull)/
|
* - remove refs/(heads|tags|pull)/
|
||||||
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
||||||
* - remove leading and trailing `-` character
|
* - remove leading `-` characters
|
||||||
* - limit the string size to 63 characters
|
* - limit the string size to 63 characters
|
||||||
|
* - remove trailing `-` characters
|
||||||
* @param envVar to be slugged
|
* @param envVar to be slugged
|
||||||
*/
|
*/
|
||||||
export function slugref_cs(envVar: string): string {
|
export function slugref_cs(envVar: string): string {
|
||||||
@@ -43,8 +48,9 @@ export function slugref_cs(envVar: string): string {
|
|||||||
* - remove refs/(heads|tags|pull)/
|
* - remove refs/(heads|tags|pull)/
|
||||||
* - put the variable content in lower case
|
* - put the variable content in lower case
|
||||||
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
||||||
* - remove leading and trailing `-` character
|
* - remove leading `-` characters
|
||||||
* - limit the string size to 63 characters
|
* - limit the string size to 63 characters
|
||||||
|
* - remove trailing `-` characters
|
||||||
* @param envVar to be slugged
|
* @param envVar to be slugged
|
||||||
*/
|
*/
|
||||||
export function slugref(envVar: string): string {
|
export function slugref(envVar: string): string {
|
||||||
@@ -54,8 +60,9 @@ export function slugref(envVar: string): string {
|
|||||||
/**
|
/**
|
||||||
* slugurl_cs will take envVar and then :
|
* slugurl_cs will take envVar and then :
|
||||||
* - replace any character by `-` except `0-9`, `a-z`
|
* - replace any character by `-` except `0-9`, `a-z`
|
||||||
* - remove leading and trailing `-` character
|
* - remove leading `-` characters
|
||||||
* - limit the string size to 63 characters
|
* - limit the string size to 63 characters
|
||||||
|
* - remove trailing `-` characters
|
||||||
* @param envVar to be slugged
|
* @param envVar to be slugged
|
||||||
*/
|
*/
|
||||||
export function slugurl_cs(envVar: string): string {
|
export function slugurl_cs(envVar: string): string {
|
||||||
@@ -66,24 +73,26 @@ export function slugurl_cs(envVar: string): string {
|
|||||||
* slugurl will take envVar and then :
|
* slugurl will take envVar and then :
|
||||||
* - put the variable content in lower case
|
* - put the variable content in lower case
|
||||||
* - replace any character by `-` except `0-9`, `a-z`
|
* - replace any character by `-` except `0-9`, `a-z`
|
||||||
* - remove leading and trailing `-` character
|
* - remove leading `-` characters
|
||||||
* - limit the string size to 63 characters
|
* - limit the string size to 63 characters
|
||||||
|
* - remove trailing `-` characters
|
||||||
* @param envVar to be slugged
|
* @param envVar to be slugged
|
||||||
*/
|
*/
|
||||||
export function slugurl(envVar: string): string {
|
export function slugurl(envVar: string): string {
|
||||||
return slug(replaceAnyNonUrlCharactersWithHyphen(envVar))
|
return slugurl_cs(envVar.toLowerCase())
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* slugurlref_cs will take envVar and then :
|
* slugurlref_cs will take envVar and then :
|
||||||
* - remove refs/(heads|tags|pull)/
|
* - remove refs/(heads|tags|pull)/
|
||||||
* - replace any character by `-` except `0-9`, `a-z`
|
* - replace any character by `-` except `0-9`, `a-z`
|
||||||
* - remove leading and trailing `-` character
|
* - remove leading `-` characters
|
||||||
* - limit the string size to 63 characters
|
* - limit the string size to 63 characters
|
||||||
|
* - remove trailing `-` characters
|
||||||
* @param envVar to be slugged
|
* @param envVar to be slugged
|
||||||
*/
|
*/
|
||||||
export function slugurlref_cs(envVar: string): string {
|
export function slugurlref_cs(envVar: string): string {
|
||||||
return slugurl_cs(slugref_cs(envVar))
|
return slugurl_cs(removeRef(envVar))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,16 +100,20 @@ export function slugurlref_cs(envVar: string): string {
|
|||||||
* - remove refs/(heads|tags|pull)/
|
* - remove refs/(heads|tags|pull)/
|
||||||
* - put the variable content in lower case
|
* - put the variable content in lower case
|
||||||
* - replace any character by `-` except `0-9`, `a-z`
|
* - replace any character by `-` except `0-9`, `a-z`
|
||||||
* - remove leading and trailing `-` character
|
* - remove leading `-` characters
|
||||||
* - limit the string size to 63 characters
|
* - limit the string size to 63 characters
|
||||||
|
* - remove trailing `-` characters
|
||||||
* @param envVar to be slugged
|
* @param envVar to be slugged
|
||||||
*/
|
*/
|
||||||
export function slugurlref(envVar: string): string {
|
export function slugurlref(envVar: string): string {
|
||||||
return slugurl(slugref(envVar))
|
return slugurlref_cs(envVar.toLowerCase())
|
||||||
}
|
}
|
||||||
|
|
||||||
function trailHyphen(envVar: string): string {
|
function removeLeadingHyphens(envVar: string): string {
|
||||||
return envVar.replace(RegExp('^-*', 'g'), '').replace(RegExp('-*$', 'g'), '')
|
return envVar.replace(RegExp('^-*', 'g'), '')
|
||||||
|
}
|
||||||
|
function removeTrailingHyphens(envVar: string): string {
|
||||||
|
return envVar.replace(RegExp('-*$', 'g'), '')
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceAnyNonAlphanumericCharacter(envVar: string): string {
|
function replaceAnyNonAlphanumericCharacter(envVar: string): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user