mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-05-18 04:15:14 +00:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a00c29bc1 | ||
|
|
c0fb0bc1a5 | ||
|
|
60beba5b25 | ||
|
|
7bf92d88ff | ||
|
|
ae2f6b069b | ||
|
|
7c02e68015 | ||
|
|
5150a26d43 | ||
|
|
dedf4ac5bb | ||
|
|
ebfc49c0e9 | ||
|
|
68babf69b3 | ||
|
|
1bf76b7bc6 | ||
|
|
46a738e36b | ||
|
|
82da1fd43c | ||
|
|
99afdf4551 | ||
|
|
944fee4603 | ||
|
|
19f9c84ac6 | ||
|
|
596b602d8a | ||
|
|
b98d94bda3 | ||
|
|
e8c1f6060b | ||
|
|
f80aa0fae4 |
19
.github/workflows/codeql-analysis.yml
vendored
19
.github/workflows/codeql-analysis.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: CodeQL
|
||||
name: '[v3] CodeQL'
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -8,7 +8,11 @@ on:
|
||||
branches:
|
||||
- v3.x
|
||||
schedule:
|
||||
- cron: "0 6 * * 1"
|
||||
- cron: '0 6 * * 1'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
analyse:
|
||||
@@ -17,12 +21,11 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: ["javascript"]
|
||||
language: ['javascript']
|
||||
steps:
|
||||
- uses: technote-space/auto-cancel-redundant-workflow@v1
|
||||
- uses: actions/checkout@v2
|
||||
- uses: github/codeql-action/init@v1
|
||||
- uses: actions/checkout@v3
|
||||
- uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- uses: github/codeql-action/autobuild@v1
|
||||
- uses: github/codeql-action/analyze@v1
|
||||
- uses: github/codeql-action/autobuild@v2
|
||||
- uses: github/codeql-action/analyze@v2
|
||||
|
||||
6
.github/workflows/github-slug.yml
vendored
6
.github/workflows/github-slug.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Github Slug testing
|
||||
name: '[v3] Testing'
|
||||
on: [push]
|
||||
jobs:
|
||||
github-slug-on-os:
|
||||
@@ -9,9 +9,11 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
- run: npm install
|
||||
shell: bash
|
||||
- run: npm run all
|
||||
shell: bash
|
||||
- uses: ./
|
||||
- name: Partial variables
|
||||
run: |
|
||||
|
||||
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/.*
|
||||
12
.github/workflows/release-dryrun.yml
vendored
12
.github/workflows/release-dryrun.yml
vendored
@@ -1,20 +1,24 @@
|
||||
name: Release DryRun
|
||||
name: '[v3] Release DryRun'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- v*.x
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
release-dryrun:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: technote-space/auto-cancel-redundant-workflow@v1
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- run: npm install
|
||||
shell: bash
|
||||
- run: npm run all
|
||||
shell: bash
|
||||
- uses: ./
|
||||
- uses: cycjimmy/semantic-release-action@v2
|
||||
- uses: cycjimmy/semantic-release-action@v3
|
||||
with:
|
||||
branches: |
|
||||
[
|
||||
|
||||
12
.github/workflows/release.yml
vendored
12
.github/workflows/release.yml
vendored
@@ -1,18 +1,22 @@
|
||||
name: Release
|
||||
name: '[v3] Release'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- v*.x
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: technote-space/auto-cancel-redundant-workflow@v1
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- run: npm install
|
||||
shell: bash
|
||||
- run: npm run all
|
||||
- uses: cycjimmy/semantic-release-action@v2
|
||||
shell: bash
|
||||
- uses: cycjimmy/semantic-release-action@v3
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
28
CHANGELOG.md
28
CHANGELOG.md
@@ -1,3 +1,31 @@
|
||||
# [3.8.0](https://github.com/rlespinasse/github-slug-action/compare/v3.7.1...v3.8.0) (2023-10-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* use node16 as action run mode ([7bf92d8](https://github.com/rlespinasse/github-slug-action/commit/7bf92d88ffb302024ab1f11ced51360f041f1b5e))
|
||||
|
||||
## [3.7.1](https://github.com/rlespinasse/github-slug-action/compare/v3.7.0...v3.7.1) (2022-10-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* use environment file to manage outputs ([dedf4ac](https://github.com/rlespinasse/github-slug-action/commit/dedf4ac5bbb50aeb6992c8323d2862843079f1b4))
|
||||
|
||||
# [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)
|
||||
|
||||
|
||||
|
||||
72
README.md
72
README.md
@@ -1,10 +1,6 @@
|
||||
# GitHub Slug action
|
||||
|
||||
[![Release][release-badge]][releases]
|
||||
![Lint][lint-badge]
|
||||
[![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
|
||||
|
||||
@@ -21,6 +17,8 @@ This GitHub Action will expose the slug/short values of [some GitHub environment
|
||||
- [Contribute](#contribute)
|
||||
- [Troubleshooting](#troubleshooting)
|
||||
- [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)
|
||||
- [Thanks for talking about us](#thanks-for-talking-about-us)
|
||||
|
||||
@@ -30,8 +28,9 @@ This GitHub Action will expose the slug/short values of [some GitHub environment
|
||||
|
||||
- put the variable content in lower case
|
||||
- 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
|
||||
- remove trailing `-` characters
|
||||
|
||||
<details>
|
||||
<summary>Others <b>Slug-ish</b> commands are available</summary>
|
||||
@@ -126,34 +125,42 @@ Follow [Developers guide](DEVELOPERS.md)
|
||||
|
||||
### 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.
|
||||
And if a custom `GITHUB_` variable is in conflict with an official `GITHUB_` variable, the offical `GITHUB_` variable will override custom one.
|
||||
If a variable start to be used as default environment variable, the environment variable may have a different behavior than the expected one.
|
||||
|
||||
<details>
|
||||
<summary>Test workflow</summary>
|
||||
<p>
|
||||
If this append, the `${{ env.GITHUB_AWESOME_VARIABLE }}` and `$GITHUB_AWESOME_VARIABLE` expression will not works in the same way.
|
||||
|
||||
- `${{ 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
|
||||
name: Test
|
||||
on: push
|
||||
jobs:
|
||||
build:
|
||||
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"
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v4
|
||||
with:
|
||||
prefix: CI_
|
||||
```
|
||||
|
||||
</p>
|
||||
</details>
|
||||
Then `${{ env.CI_GITHUB_REF_NAME }}`, and `$CI_GITHUB_REF_NAME` will serve the behavior of this action.
|
||||
And `$GITHUB_REF_NAME` will serve the behavior of GitHub Action.
|
||||
|
||||
### An action could not be found at the URI
|
||||
|
||||
@@ -177,19 +184,16 @@ Please, use the current branch `v3.x` or a version tag (see [releases pages][rel
|
||||
- [Action spotlight by Michael Heap][article-2]
|
||||
- The next one is you. _Don't hesitate to add youself to this list._
|
||||
|
||||
[release-badge]: https://img.shields.io/github/workflow/status/rlespinasse/github-slug-action/Release?label=Build&logo=github&style=flat-square
|
||||
[lint-badge]: https://img.shields.io/github/workflow/status/rlespinasse/github-slug-action/Lint?label=Lint&logo=github&style=flat-square
|
||||
[license-badge]: https://img.shields.io/github/license/rlespinasse/github-slug-action?style=flat-square
|
||||
|
||||
[actions]: https://github.com/rlespinasse/github-slug-action/actions
|
||||
[license]: https://github.com/rlespinasse/github-slug-action/blob/v3.x/LICENSE
|
||||
[examples]: https://github.com/rlespinasse/github-slug-action/tree/v3.x/examples
|
||||
[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
|
||||
[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
|
||||
[dependabot]: https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot
|
||||
[default-environment-variables]: https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
||||
[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
|
||||
[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: an underscore', () => {
|
||||
test_slug('An_Underscore', 'an_underscore')
|
||||
test_slug_cs('An_Underscore', 'An_Underscore')
|
||||
})
|
||||
|
||||
test('slug: special character', () => {
|
||||
test_slug('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(
|
||||
'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-moreThan63Characters',
|
||||
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||
)
|
||||
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'
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||
)
|
||||
})
|
||||
|
||||
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'
|
||||
'-has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters-',
|
||||
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||
)
|
||||
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'
|
||||
'-has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters-',
|
||||
'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('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_slugref('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_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'
|
||||
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||
)
|
||||
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'
|
||||
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'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('slug_url: an underscore', () => {
|
||||
test_slugurl('An_Underscore', 'an-underscore')
|
||||
test_slugurl_cs('An_Underscore', 'An-Underscore')
|
||||
})
|
||||
|
||||
test('slug_url: trailing', () => {
|
||||
test_slugurl('.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_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'
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||
)
|
||||
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'
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'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('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_slugurlref('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_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'
|
||||
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||
)
|
||||
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'
|
||||
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ name: "GitHub Slug Action"
|
||||
description: "GitHub Action to expose slug value of environment variables inside your GitHub workflow"
|
||||
author: 'rlespinasse'
|
||||
runs:
|
||||
using: 'node12'
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
branding:
|
||||
icon: "minimize"
|
||||
|
||||
3368
dist/index.js
vendored
3368
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
3913
dist/sourcemap-register.js
vendored
3913
dist/sourcemap-register.js
vendored
File diff suppressed because one or more lines are too long
16796
package-lock.json
generated
16796
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
33
package.json
33
package.json
@@ -17,7 +17,7 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/rlespinasse/github-slug-action.git"
|
||||
"url": "https://github.com/rlespinasse/github-slug-action.git"
|
||||
},
|
||||
"keywords": [
|
||||
"actions",
|
||||
@@ -26,32 +26,32 @@
|
||||
],
|
||||
"author": "rlespinasse",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6"
|
||||
"@actions/core": "^1.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "^5.0.1",
|
||||
"@semantic-release/exec": "^5.0.0",
|
||||
"@semantic-release/git": "^9.0.0",
|
||||
"@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",
|
||||
"@semantic-release/changelog": "^6.0.1",
|
||||
"@semantic-release/exec": "^6.0.0",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/node": "^14.18.25",
|
||||
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-plugin-github": "^4.3.7",
|
||||
"eslint-plugin-jest": "^23.20.0",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^26.6.3",
|
||||
"js-yaml": "^3.14.1",
|
||||
"prettier": "^2.2.1",
|
||||
"semantic-release": "^17.4.0",
|
||||
"ts-jest": "^26.4.4",
|
||||
"typescript": "^3.9.7"
|
||||
"prettier": "^2.7.1",
|
||||
"semantic-release": "^19.0.3",
|
||||
"ts-jest": "^26.5.6",
|
||||
"typescript": "^4.2.0"
|
||||
},
|
||||
"files": [
|
||||
"/dist"
|
||||
],
|
||||
"release": {
|
||||
"tagFormat": "${version}",
|
||||
"tagFormat": "v${version}",
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
@@ -66,7 +66,6 @@
|
||||
"@semantic-release/github"
|
||||
],
|
||||
"branches": [
|
||||
"v2.x",
|
||||
"v3.x"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ async function run(): Promise<void> {
|
||||
|
||||
exportBranchName()
|
||||
} 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 :
|
||||
* - 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
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slug_cs(envVar: string): string {
|
||||
return trailHyphen(replaceAnyNonAlphanumericCharacter(envVar)).substring(
|
||||
0,
|
||||
MAX_SLUG_STRING_SIZE
|
||||
return removeTrailingHyphens(
|
||||
removeLeadingHyphens(replaceAnyNonAlphanumericCharacter(envVar)).substring(
|
||||
0,
|
||||
MAX_SLUG_STRING_SIZE
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -18,8 +21,9 @@ export function slug_cs(envVar: string): string {
|
||||
* 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
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slug(envVar: string): string {
|
||||
@@ -30,8 +34,9 @@ export function slug(envVar: string): string {
|
||||
* 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
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugref_cs(envVar: string): string {
|
||||
@@ -43,8 +48,9 @@ export function slugref_cs(envVar: string): string {
|
||||
* - 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
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugref(envVar: string): string {
|
||||
@@ -54,8 +60,9 @@ export function slugref(envVar: string): string {
|
||||
/**
|
||||
* slugurl_cs will take envVar and then :
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading and trailing `-` character
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugurl_cs(envVar: string): string {
|
||||
@@ -66,24 +73,26 @@ export function slugurl_cs(envVar: string): string {
|
||||
* 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
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugurl(envVar: string): string {
|
||||
return slug(replaceAnyNonUrlCharactersWithHyphen(envVar))
|
||||
return slugurl_cs(envVar.toLowerCase())
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
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)/
|
||||
* - put the variable content in lower case
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading and trailing `-` character
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugurlref(envVar: string): string {
|
||||
return slugurl(slugref(envVar))
|
||||
return slugurlref_cs(envVar.toLowerCase())
|
||||
}
|
||||
|
||||
function trailHyphen(envVar: string): string {
|
||||
return envVar.replace(RegExp('^-*', 'g'), '').replace(RegExp('-*$', 'g'), '')
|
||||
function removeLeadingHyphens(envVar: string): string {
|
||||
return envVar.replace(RegExp('^-*', 'g'), '')
|
||||
}
|
||||
function removeTrailingHyphens(envVar: string): string {
|
||||
return envVar.replace(RegExp('-*$', 'g'), '')
|
||||
}
|
||||
|
||||
function replaceAnyNonAlphanumericCharacter(envVar: string): string {
|
||||
|
||||
Reference in New Issue
Block a user