mirror of
https://github.com/rlespinasse/slugify-value.git
synced 2026-05-17 18:25:47 +00:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4212caf3f | ||
|
|
d6e3cb1498 | ||
|
|
a6cb4bed66 | ||
|
|
93d9285b74 | ||
|
|
377ba97cc7 | ||
|
|
341a4b67d7 | ||
|
|
45c76a9806 | ||
|
|
ee83cf0807 | ||
|
|
d1b958d592 | ||
|
|
332172c7f4 | ||
|
|
dbd1cbdf50 | ||
|
|
cbec62b21f | ||
|
|
a4879db1eb | ||
|
|
1d53af49fb | ||
|
|
f1c7463d0d | ||
|
|
4e258f56ef | ||
|
|
930d4521cc | ||
|
|
cb3e46ca61 | ||
|
|
cb5f2aad22 | ||
|
|
1ce1e1b126 | ||
|
|
38f26c3445 | ||
|
|
ae545a3d5d | ||
|
|
1300b1ecaf | ||
|
|
ce66c2e7e3 | ||
|
|
ca7a5a0fdd | ||
|
|
8c6e40fa30 | ||
|
|
e0e1ac60ae | ||
|
|
c12f1d6d88 | ||
|
|
dd418141ff | ||
|
|
971b114f9b | ||
|
|
94d3accefd |
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* @rlespinasse
|
||||
3
.github/FUNDING.yml
vendored
Normal file
3
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: rlespinasse
|
||||
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
23
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: 'github-actions'
|
||||
directory: '/'
|
||||
schedule:
|
||||
interval: 'weekly'
|
||||
groups:
|
||||
dependencies:
|
||||
patterns:
|
||||
- '*'
|
||||
labels: []
|
||||
30
.github/workflows/linter.yml
vendored
Normal file
30
.github/workflows/linter.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
name: Lint Code Base
|
||||
|
||||
on: pull_request
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Lint Code Base
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
statuses: write
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
# Full git history is needed to get a proper
|
||||
# list of changed files within `super-linter`
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Lint Code Base
|
||||
uses: super-linter/super-linter@v8
|
||||
env:
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
|
||||
VALIDATE_YAML_PRETTIER: false
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
198
.github/workflows/slugify-value.yaml
vendored
Normal file
198
.github/workflows/slugify-value.yaml
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
---
|
||||
name: Slugify Value
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- v1.x
|
||||
pull_request:
|
||||
|
||||
permissions: read-all
|
||||
|
||||
# Disable line length check due to the content of the tests
|
||||
# yamllint disable rule:line-length
|
||||
jobs:
|
||||
os-testing:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
# Test 1
|
||||
- name: Slugify key only
|
||||
id: slugify-key-only
|
||||
uses: ./
|
||||
with:
|
||||
key: KEY_ONLY
|
||||
env:
|
||||
KEY_ONLY: "refs/head/$-Key_Only.test--value-%-+"
|
||||
- name: Validate // Slugify key only
|
||||
# Disable SC2193 because the first line of the test is flag by shellcheck
|
||||
# as the comparison can never be equal but the test pass.
|
||||
# Seem a false-positive due to the test context.
|
||||
run: |
|
||||
# shellcheck disable=SC2193
|
||||
[[ "${{ env.KEY_ONLY }}" == "refs/head/$-Key_Only.test--value-%-+" ]]
|
||||
[[ "${{ env.KEY_ONLY_SLUG }}" == "key_only.test--value" ]]
|
||||
[[ "${{ env.KEY_ONLY_SLUG_CS }}" == "Key_Only.test--value" ]]
|
||||
[[ "${{ env.KEY_ONLY_SLUG_URL }}" == "key-only-test--value" ]]
|
||||
[[ "${{ env.KEY_ONLY_SLUG_URL_CS }}" == "Key-Only-test--value" ]]
|
||||
[[ "${{ env.KEY_ONLY }}" == "${{ steps.slugify-key-only.outputs.value }}" ]]
|
||||
[[ "${{ env.KEY_ONLY_SLUG }}" == "${{ steps.slugify-key-only.outputs.slug }}" ]]
|
||||
[[ "${{ env.KEY_ONLY_SLUG_CS }}" == "${{ steps.slugify-key-only.outputs.slug-cs }}" ]]
|
||||
[[ "${{ env.KEY_ONLY_SLUG_URL }}" == "${{ steps.slugify-key-only.outputs.slug-url }}" ]]
|
||||
[[ "${{ env.KEY_ONLY_SLUG_URL_CS }}" == "${{ steps.slugify-key-only.outputs.slug-url-cs }}" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 2
|
||||
- name: Slugify key only with prefix
|
||||
uses: ./
|
||||
with:
|
||||
key: KEY_ONLY_WITH_PREFIX
|
||||
prefix: CI_
|
||||
env:
|
||||
KEY_ONLY_WITH_PREFIX: ${{ env.KEY_ONLY }}
|
||||
- name: Validate // Slugify key only with prefix
|
||||
run: |
|
||||
[[ "${{ env.CI_KEY_ONLY_WITH_PREFIX }}" == "${{ env.KEY_ONLY }}" ]]
|
||||
[[ "${{ env.CI_KEY_ONLY_WITH_PREFIX_SLUG }}" == "${{ env.KEY_ONLY_SLUG }}" ]]
|
||||
[[ "${{ env.CI_KEY_ONLY_WITH_PREFIX_SLUG_CS }}" == "${{ env.KEY_ONLY_SLUG_CS }}" ]]
|
||||
[[ "${{ env.CI_KEY_ONLY_WITH_PREFIX_SLUG_URL }}" == "${{ env.KEY_ONLY_SLUG_URL }}" ]]
|
||||
[[ "${{ env.CI_KEY_ONLY_WITH_PREFIX_SLUG_URL_CS }}" == "${{ env.KEY_ONLY_SLUG_URL_CS }}" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 3
|
||||
- name: Slugify key/value
|
||||
uses: ./
|
||||
with:
|
||||
key: KEY_VALUE
|
||||
value: "Never gonna give you up Never gonna let you down"
|
||||
- name: Validate // Slugify key/value
|
||||
run: |
|
||||
[[ "${{ env.KEY_VALUE }}" == "Never gonna give you up Never gonna let you down" ]]
|
||||
[[ "${{ env.KEY_VALUE_SLUG }}" == "never-gonna-give-you-up-never-gonna-let-you-down" ]]
|
||||
[[ "${{ env.KEY_VALUE_SLUG_CS }}" == "Never-gonna-give-you-up-Never-gonna-let-you-down" ]]
|
||||
[[ "${{ env.KEY_VALUE_SLUG_URL }}" == "never-gonna-give-you-up-never-gonna-let-you-down" ]]
|
||||
[[ "${{ env.KEY_VALUE_SLUG_URL_CS }}" == "Never-gonna-give-you-up-Never-gonna-let-you-down" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 4
|
||||
- name: Slugify with another max length
|
||||
uses: ./
|
||||
with:
|
||||
key: ANOTHER_MAX_LENGTH
|
||||
value: "Never gonna give you up Never gonna let you down"
|
||||
slug-maxlength: 24
|
||||
- name: Validate // Slugify with another max length
|
||||
run: |
|
||||
[[ "${{ env.ANOTHER_MAX_LENGTH }}" == "Never gonna give you up Never gonna let you down" ]]
|
||||
[[ "${{ env.ANOTHER_MAX_LENGTH_SLUG }}" == "never-gonna-give-you-up" ]]
|
||||
[[ "${{ env.ANOTHER_MAX_LENGTH_SLUG_CS }}" == "Never-gonna-give-you-up" ]]
|
||||
[[ "${{ env.ANOTHER_MAX_LENGTH_SLUG_URL }}" == "never-gonna-give-you-up" ]]
|
||||
[[ "${{ env.ANOTHER_MAX_LENGTH_SLUG_URL_CS }}" == "Never-gonna-give-you-up" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 5
|
||||
- name: Slugify with no limit on max length
|
||||
uses: ./
|
||||
with:
|
||||
key: NO_MAX_LENGTH
|
||||
value: "Never gonna give you up Never gonna let you down Never gonna run around and desert you Never gonna make you cry Never gonna say goodbye Never gonna tell a lie and hurt you"
|
||||
slug-maxlength: "nolimit"
|
||||
- name: Validate // Slugify with no limit on max length
|
||||
run: |
|
||||
[[ "${{ env.NO_MAX_LENGTH }}" == "Never gonna give you up Never gonna let you down Never gonna run around and desert you Never gonna make you cry Never gonna say goodbye Never gonna tell a lie and hurt you" ]]
|
||||
[[ "${{ env.NO_MAX_LENGTH_SLUG }}" == "never-gonna-give-you-up-never-gonna-let-you-down-never-gonna-run-around-and-desert-you-never-gonna-make-you-cry-never-gonna-say-goodbye-never-gonna-tell-a-lie-and-hurt-you" ]]
|
||||
[[ "${{ env.NO_MAX_LENGTH_SLUG_CS }}" == "Never-gonna-give-you-up-Never-gonna-let-you-down-Never-gonna-run-around-and-desert-you-Never-gonna-make-you-cry-Never-gonna-say-goodbye-Never-gonna-tell-a-lie-and-hurt-you" ]]
|
||||
[[ "${{ env.NO_MAX_LENGTH_SLUG_URL }}" == "never-gonna-give-you-up-never-gonna-let-you-down-never-gonna-run-around-and-desert-you-never-gonna-make-you-cry-never-gonna-say-goodbye-never-gonna-tell-a-lie-and-hurt-you" ]]
|
||||
[[ "${{ env.NO_MAX_LENGTH_SLUG_URL_CS }}" == "Never-gonna-give-you-up-Never-gonna-let-you-down-Never-gonna-run-around-and-desert-you-Never-gonna-make-you-cry-Never-gonna-say-goodbye-Never-gonna-tell-a-lie-and-hurt-you" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 6
|
||||
- name: Slugify with empty max length
|
||||
id: slugify-with-empty-max-length
|
||||
uses: ./
|
||||
with:
|
||||
key: EMPTY_MAXLENGTH
|
||||
value: some_value
|
||||
slug-maxlength: ""
|
||||
continue-on-error: true
|
||||
- name: Validate // Slugify with empty max length
|
||||
run: |
|
||||
[[ -z "${{ env.EMPTY_MAXLENGTH }}" ]]
|
||||
[[ -z "${{ env.EMPTY_MAXLENGTH_SLUG }}" ]]
|
||||
[[ -z "${{ env.EMPTY_MAXLENGTH_SLUG_CS }}" ]]
|
||||
[[ -z "${{ env.EMPTY_MAXLENGTH_SLUG_URL }}" ]]
|
||||
[[ -z "${{ env.EMPTY_MAXLENGTH_SLUG_URL_CS }}" ]]
|
||||
[[ "${{ steps.slugify-with-empty-max-length.outcome }}" == "failure" ]]
|
||||
[[ "${{ steps.slugify-with-empty-max-length.conclusion }}" == "success" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 7
|
||||
- name: Slugify with wrong max length
|
||||
id: slugify-with-wrong-max-length
|
||||
uses: ./
|
||||
with:
|
||||
key: WRONG_MAXLENGTH
|
||||
value: some_value
|
||||
slug-maxlength: "wrong"
|
||||
continue-on-error: true
|
||||
- name: Validate // Slugify with wrong max length
|
||||
run: |
|
||||
[[ -z "${{ env.WRONG_MAXLENGTH }}" ]]
|
||||
[[ -z "${{ env.WRONG_MAXLENGTH_SLUG }}" ]]
|
||||
[[ -z "${{ env.WRONG_MAXLENGTH_SLUG_CS }}" ]]
|
||||
[[ -z "${{ env.WRONG_MAXLENGTH_SLUG_URL }}" ]]
|
||||
[[ -z "${{ env.WRONG_MAXLENGTH_SLUG_URL_CS }}" ]]
|
||||
[[ "${{ steps.slugify-with-wrong-max-length.outcome }}" == "failure" ]]
|
||||
[[ "${{ steps.slugify-with-wrong-max-length.conclusion }}" == "success" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 8
|
||||
- name: Slugify key without env publication
|
||||
id: slugify-key-without-env-publication
|
||||
uses: ./
|
||||
with:
|
||||
key: KEY_WITHOUT_ENV_PUBLICATION
|
||||
publish-env: false
|
||||
env:
|
||||
KEY_WITHOUT_ENV_PUBLICATION: "Never gonna give you up"
|
||||
- name: Validate // Slugify key without env publication
|
||||
run: |
|
||||
[[ -z "${{ env.KEY_WITHOUT_ENV_PUBLICATION }}" ]]
|
||||
[[ -z "${{ env.KEY_WITHOUT_ENV_PUBLICATION_SLUG }}" ]]
|
||||
[[ -z "${{ env.KEY_WITHOUT_ENV_PUBLICATION_SLUG_CS }}" ]]
|
||||
[[ -z "${{ env.KEY_WITHOUT_ENV_PUBLICATION_SLUG_URL }}" ]]
|
||||
[[ -z "${{ env.KEY_WITHOUT_ENV_PUBLICATION_SLUG_URL_CS }}" ]]
|
||||
[[ "${{ steps.slugify-key-without-env-publication.outputs.value }}" == "Never gonna give you up" ]]
|
||||
[[ "${{ steps.slugify-key-without-env-publication.outputs.slug }}" == "never-gonna-give-you-up" ]]
|
||||
[[ "${{ steps.slugify-key-without-env-publication.outputs.slug-cs }}" == "Never-gonna-give-you-up" ]]
|
||||
[[ "${{ steps.slugify-key-without-env-publication.outputs.slug-url }}" == "never-gonna-give-you-up" ]]
|
||||
[[ "${{ steps.slugify-key-without-env-publication.outputs.slug-url-cs }}" == "Never-gonna-give-you-up" ]]
|
||||
shell: bash
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
id-token: write
|
||||
packages: write
|
||||
concurrency:
|
||||
group: release-${{ github.ref }}
|
||||
needs:
|
||||
- os-testing
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
# Release
|
||||
- name: Release this GitHub Action
|
||||
uses: rlespinasse/release-that@v1
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
55
.github/workflows/slugify.yaml
vendored
55
.github/workflows/slugify.yaml
vendored
@@ -1,55 +0,0 @@
|
||||
name: Slugify testing
|
||||
on: [push]
|
||||
jobs:
|
||||
slugify-on-os:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Test 1
|
||||
- name: Slugify key only
|
||||
uses: ./
|
||||
with:
|
||||
key: KEY_TEST
|
||||
env:
|
||||
KEY_TEST: Key_Test.values
|
||||
- name: Test result of key only
|
||||
run: |
|
||||
[[ "${{ env.KEY_TEST }}" == "Key_Test.values" ]]
|
||||
[[ "${{ env.KEY_TEST_SLUG }}" == "key_test.values" ]]
|
||||
[[ "${{ env.KEY_TEST_SLUG_CS }}" == "Key_Test.values" ]]
|
||||
[[ "${{ env.KEY_TEST_SLUG_URL }}" == "key_test-values" ]]
|
||||
[[ "${{ env.KEY_TEST_SLUG_URL_CS }}" == "Key_Test-values" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 2
|
||||
- name: Slugify key/value
|
||||
uses: ./
|
||||
with:
|
||||
key: KEY_VALUE_TEST
|
||||
value: refs/pulls/feat/-----Some----Changes_to.be------
|
||||
- name: Test result of key only
|
||||
run: |
|
||||
[[ "${{ env.KEY_VALUE_TEST }}" == "refs/pulls/feat/-----Some----Changes_to.be------" ]]
|
||||
[[ "${{ env.KEY_VALUE_TEST_SLUG }}" == "feat-some-changes_to.be" ]]
|
||||
[[ "${{ env.KEY_VALUE_TEST_SLUG_CS }}" == "feat-Some-Changes_to.be" ]]
|
||||
[[ "${{ env.KEY_VALUE_TEST_SLUG_URL }}" == "feat-some-changes_to-be" ]]
|
||||
[[ "${{ env.KEY_VALUE_TEST_SLUG_URL_CS }}" == "feat-Some-Changes_to-be" ]]
|
||||
shell: bash
|
||||
|
||||
slugify-release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: slugify-on-os
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Release
|
||||
- name: Release this GitHub Action
|
||||
uses: rlespinasse/release-that@v1.x
|
||||
|
||||
@@ -6,8 +6,8 @@ We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||
identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
@@ -22,17 +22,17 @@ community include:
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
* Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||
any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
@@ -52,7 +52,7 @@ decisions when appropriate.
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
Examples of representing our community include using an official email address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
@@ -60,7 +60,7 @@ representative at an online or offline event.
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
romain.lespinasse@gmail.com.
|
||||
<romain.lespinasse@gmail.com>.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
@@ -82,15 +82,15 @@ behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
@@ -106,23 +106,27 @@ Violating these terms may lead to a permanent ban.
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||
community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
version 2.1, available at
|
||||
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||
[https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
|
||||
33
CONTRIBUTING.md
Normal file
33
CONTRIBUTING.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# How to contribute to Slugify Value
|
||||
|
||||
## Did you find a bug
|
||||
|
||||
* **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead to refer to our [security policy][1].
|
||||
|
||||
* **Ensure the bug was not already reported** by searching on GitHub under [Issues][2].
|
||||
|
||||
* If you're unable to find an open issue addressing the problem, [open a 'Bug' issue][4].
|
||||
Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
|
||||
|
||||
## Did you write a patch that fixes a bug
|
||||
|
||||
* Open a new GitHub pull request with the patch.
|
||||
|
||||
* Ensure the PR description clearly describes the problem and solution.
|
||||
Include the relevant issue number if applicable.
|
||||
|
||||
## Do you intend to add a new feature or change an existing one
|
||||
|
||||
* Suggest your change by [opening a 'Feature request' issue][5]
|
||||
|
||||
## Do you have questions about the source code
|
||||
|
||||
* [open an issue][3] with your question.
|
||||
|
||||
Thanks!
|
||||
|
||||
[1]: https://github.com/rlespinasse/slugify-value/security/policy
|
||||
[2]: https://github.com/rlespinasse/slugify-value/issues
|
||||
[3]: https://github.com/rlespinasse/slugify-value/issues/new
|
||||
[4]: https://github.com/rlespinasse/slugify-value/issues/new?assignees=&labels=bug&template=bug_report.md&title=
|
||||
[5]: https://github.com/rlespinasse/slugify-value/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=
|
||||
110
README.md
110
README.md
@@ -1,30 +1,32 @@
|
||||
# Slugify
|
||||
|
||||
> Github Action to slugify a value
|
||||
> [!NOTE]
|
||||
> A GitHub Action that transforms input strings into URL-friendly slugs
|
||||
|
||||
Produce some `slug`-ed environment variables based on the input one.
|
||||
This action creates standardized slug versions of your input variables, offering multiple formatting options:
|
||||
|
||||
## Output Formats
|
||||
|
||||
- `<env name>_SLUG`
|
||||
|
||||
- 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
|
||||
|
||||
- Converts text to lowercase
|
||||
- Replaces special characters with **-** (except **0-9**, **a-z**, **.**, and **_**)
|
||||
- Removes leading and trailing **-$*
|
||||
- Limits string length to **63** characters
|
||||
- `<env name>_SLUG_CS`
|
||||
- Same as `_SLUG` but preserves original case sensitivity
|
||||
- `<env name>_SLUG_URL` and `<env name>_SLUG_URL_CS`
|
||||
- Same as their respective base versions (`_SLUG` or `_SLUG_CS`)
|
||||
- Additionally replaces **.** and **_** with **-**
|
||||
- Perfect for URL-safe strings
|
||||
|
||||
- like `<env name>_SLUG` but the content is not put in lower case
|
||||
|
||||
- `<env name>_SLUG_URL` (or `<env name>_SLUG_URL_CS`)
|
||||
|
||||
- like `<env name>_SLUG` (or `<env name>_SLUG_CS`) with the `.` character also replaced by `-`
|
||||
Each output variable maintains consistent formatting rules while serving different use cases, from basic slugification to URL-ready strings.
|
||||
|
||||
## Usage
|
||||
|
||||
- Slugify a value and store it using a key
|
||||
|
||||
```yaml
|
||||
- uses: rlespinasse/slugify@v1.x
|
||||
- uses: rlespinasse/slugify-value@v1.x
|
||||
with:
|
||||
key: KEY_NAME
|
||||
value: value_to_slugify
|
||||
@@ -32,6 +34,7 @@ Produce some `slug`-ed environment variables based on the input one.
|
||||
|
||||
Will make available
|
||||
|
||||
- `KEY_NAME`
|
||||
- `KEY_NAME_SLUG`
|
||||
- `KEY_NAME_SLUG_CS`
|
||||
- `KEY_NAME_SLUG_URL`
|
||||
@@ -40,7 +43,7 @@ Produce some `slug`-ed environment variables based on the input one.
|
||||
- Slugify the value of an environment variable
|
||||
|
||||
```yaml
|
||||
- uses: rlespinasse/slugify@v1.x
|
||||
- uses: rlespinasse/slugify-value@v1.x
|
||||
with:
|
||||
key: EXISTING_ENV_VAR
|
||||
```
|
||||
@@ -51,3 +54,80 @@ Produce some `slug`-ed environment variables based on the input one.
|
||||
- `EXISTING_ENV_VAR_SLUG_CS`
|
||||
- `EXISTING_ENV_VAR_SLUG_URL`
|
||||
- `EXISTING_ENV_VAR_SLUG_URL_CS`
|
||||
|
||||
- Slugify the value of an environment variable with prefix
|
||||
|
||||
```yaml
|
||||
- uses: rlespinasse/slugify-value@v1.x
|
||||
with:
|
||||
key: EXISTING_ENV_VAR
|
||||
prefix: CI_
|
||||
```
|
||||
|
||||
Will make available
|
||||
|
||||
- `CI_EXISTING_ENV_VAR`
|
||||
- `CI_EXISTING_ENV_VAR_SLUG`
|
||||
- `CI_EXISTING_ENV_VAR_SLUG_CS`
|
||||
- `CI_EXISTING_ENV_VAR_SLUG_URL`
|
||||
- `CI_EXISTING_ENV_VAR_SLUG_URL_CS`
|
||||
|
||||
- Slugify a value with a different slug length
|
||||
|
||||
```yaml
|
||||
- uses: rlespinasse/slugify-value@v1.x
|
||||
with:
|
||||
key: EXISTING_ENV_VAR
|
||||
slug-maxlength: 80
|
||||
```
|
||||
|
||||
Will produce SLUG variables with a 80-char length
|
||||
|
||||
- Slugify a value without length limit
|
||||
|
||||
```yaml
|
||||
- uses: rlespinasse/slugify-value@v1.x
|
||||
with:
|
||||
key: EXISTING_ENV_VAR
|
||||
slug-maxlength: "nolimit"
|
||||
```
|
||||
|
||||
Will produce SLUG variables without limiting the output length
|
||||
|
||||
- Slugify a value without publishing the environment variables
|
||||
|
||||
```yaml
|
||||
- uses: rlespinasse/slugify-value@v1.x
|
||||
with:
|
||||
key: KEY_NAME
|
||||
value: value_to_slugify
|
||||
publish-env: false
|
||||
```
|
||||
|
||||
Will **not** make available
|
||||
|
||||
- `KEY_NAME`
|
||||
- `KEY_NAME_SLUG`
|
||||
- `KEY_NAME_SLUG_CS`
|
||||
- `KEY_NAME_SLUG_URL`
|
||||
- `KEY_NAME_SLUG_URL_CS`
|
||||
|
||||
## Inputs
|
||||
|
||||
| Input | Description | Mandatory | Default |
|
||||
| -------------- | ----------------------------------------------------------------------------------------------------- | --------- | ------- |
|
||||
| key | Environment variable that will hold the value and serve as prefix to slugified value | Yes | |
|
||||
| value | The value to slugify. If not set the value will be taken from the `key` input as environment variable | No | |
|
||||
| prefix | The value will be prepend to each generated variable | No | |
|
||||
| slug-maxlength | The value is a number or `nolimit` to reflect the length of the slug outputs | No | 63 |
|
||||
| publish-env | In addition of the action output, the slug values are publish as environment variables | No | true |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Output | Description |
|
||||
| ----------- | ------------------------------- |
|
||||
| value | The value to be slugify |
|
||||
| slug | Value Slug |
|
||||
| slug-cs | Value Slug (Case-sensitive) |
|
||||
| slug-url | Value Slug URL |
|
||||
| slug-url-cs | Value Slug URL (Case-sensitive) |
|
||||
|
||||
22
SECURITY.md
Normal file
22
SECURITY.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions and Branches
|
||||
|
||||
| Version | Supported | End of Support | Branch | Specific Tags |
|
||||
| ------- | ------------------ | -------------- | ------ | ------------- |
|
||||
| 1.x | :white_check_mark: | | v1.x | v1 |
|
||||
|
||||
A GitHub repository can use one of the available branches as an action inside its workflows.
|
||||
|
||||
### End of Life of a branch
|
||||
|
||||
Since `2024-10-26`, when a new major version is released,
|
||||
|
||||
- The previous one will continue to receive security patches for 3 months,
|
||||
- After the 3 months, the branch is deleted, and only the tags remain.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
In this project, you can report a Vulnerability by creating a [draft security advisory](https://github.com/rlespinasse/slugify-value/security/advisories).
|
||||
|
||||
If the vulnerability is confirmed, a fix will be produced and the advisory will be published.
|
||||
40
action.yml
40
action.yml
@@ -1,6 +1,9 @@
|
||||
name: "Slugify Value"
|
||||
description: "Github Action to slugify a value"
|
||||
author: "Romain Lespinasse"
|
||||
branding:
|
||||
icon: "crop"
|
||||
color: "gray-dark"
|
||||
inputs:
|
||||
key:
|
||||
description: "Environment variable that will hold the value and serve as prefix to slugified value"
|
||||
@@ -8,14 +11,43 @@ inputs:
|
||||
value:
|
||||
description: "Value to slugify"
|
||||
required: false
|
||||
branding:
|
||||
icon: "crop"
|
||||
color: "gray-dark"
|
||||
prefix:
|
||||
description: "Value to prepend to each generated variable"
|
||||
default: ""
|
||||
required: false
|
||||
slug-maxlength:
|
||||
description: "Max length of the slugified values"
|
||||
default: "63"
|
||||
required: true
|
||||
publish-env:
|
||||
description: "Publish slugs as environment variables"
|
||||
default: "true"
|
||||
required: true
|
||||
outputs:
|
||||
value:
|
||||
description: "The value to be slugify"
|
||||
value: ${{ steps.slugify.outputs.value }}
|
||||
slug:
|
||||
description: "Value Slug"
|
||||
value: ${{ steps.slugify.outputs.slug }}
|
||||
slug-cs:
|
||||
description: "Value Slug (Case-sensitive)"
|
||||
value: ${{ steps.slugify.outputs.slug-cs }}
|
||||
slug-url:
|
||||
description: "Value Slug URL"
|
||||
value: ${{ steps.slugify.outputs.slug-url }}
|
||||
slug-url-cs:
|
||||
description: "Value Slug URL (Case-sensitive)"
|
||||
value: ${{ steps.slugify.outputs.slug-url-cs }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- run: $GITHUB_ACTION_PATH/slugify.sh
|
||||
- id: slugify
|
||||
run: $GITHUB_ACTION_PATH/slugify.sh
|
||||
shell: bash
|
||||
env:
|
||||
INPUT_KEY: ${{ inputs.key }}
|
||||
INPUT_VALUE: ${{ inputs.value }}
|
||||
INPUT_PREFIX: ${{ inputs.prefix }}
|
||||
INPUT_SLUG_MAXLENGTH: ${{ inputs.slug-maxlength }}
|
||||
INPUT_PUBLISH_ENV: ${{ inputs.publish-env }}
|
||||
|
||||
77
slugify.sh
77
slugify.sh
@@ -6,28 +6,79 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
KEY=$(echo "$INPUT_KEY" | tr '[:lower:]' '[:upper:]')
|
||||
CS_VALUE=${INPUT_VALUE:-${!INPUT_KEY}}
|
||||
VALUE=$(echo "$CS_VALUE" | tr '[:upper:]' '[:lower:]')
|
||||
PREFIX=$(echo "$INPUT_PREFIX" | tr '[:lower:]' '[:upper:]')
|
||||
else
|
||||
KEY=${INPUT_KEY^^}
|
||||
CS_VALUE=${INPUT_VALUE:-${!INPUT_KEY}}
|
||||
VALUE=${CS_VALUE,,}
|
||||
PREFIX=${INPUT_PREFIX^^}
|
||||
fi
|
||||
|
||||
MAX_LENGTH=""
|
||||
if [ -z "${INPUT_SLUG_MAXLENGTH}" ]; then
|
||||
echo "::error ::slug-maxlength cannot be empty"
|
||||
exit 1
|
||||
elif [ "${INPUT_SLUG_MAXLENGTH}" -eq "${INPUT_SLUG_MAXLENGTH}" ] 2>/dev/null; then
|
||||
MAX_LENGTH="${INPUT_SLUG_MAXLENGTH}"
|
||||
elif [ "${INPUT_SLUG_MAXLENGTH}" == "nolimit" ]; then
|
||||
MAX_LENGTH="${INPUT_SLUG_MAXLENGTH}"
|
||||
else
|
||||
echo "::error ::slug-maxlength must be a number or equals to 'nolimit'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
slug() {
|
||||
echo "$1" |
|
||||
sed -E 's#refs/[^\/]*/##;s/[^a-zA-Z0-9._]+/-/g;s/-+/-/g;s/^-*//;s/-*$//' |
|
||||
cut -c1-63
|
||||
# 1st : Remove refs prefix
|
||||
# 2d : Replace unwanted characters
|
||||
# 3d : Remove leading hypens
|
||||
output=$(sed -E 's#refs/[^\/]*/##;s/[^a-zA-Z0-9._-]+/-/g;s/^-*//' <<<"$1")
|
||||
reduce "$output"
|
||||
}
|
||||
|
||||
slug_url() {
|
||||
echo "$1" |
|
||||
sed -E 's#refs/[^\/]*/##;s/[^a-zA-Z0-9_]+/-/g;s/-+/-/g;s/^-*//;s/-*$//' |
|
||||
cut -c1-63
|
||||
# 1st : Remove refs prefix
|
||||
# 2d : Replace unwanted characters
|
||||
# 3d : Remove leading hypens
|
||||
output=$(sed -E 's#refs/[^\/]*/##;s/[^a-zA-Z0-9-]+/-/g;s/^-*//' <<<"$1")
|
||||
reduce "$output"
|
||||
}
|
||||
|
||||
{
|
||||
echo "${KEY}=${CS_VALUE}"
|
||||
echo "${KEY}_SLUG=$(slug "$VALUE")"
|
||||
echo "${KEY}_SLUG_CS=$(slug "$CS_VALUE")"
|
||||
echo "${KEY}_SLUG_URL=$(slug_url "$VALUE")"
|
||||
echo "${KEY}_SLUG_URL_CS=$(slug_url "$CS_VALUE")"
|
||||
} >>"$GITHUB_ENV"
|
||||
reduce() {
|
||||
reduced_value="$1"
|
||||
if [ "${MAX_LENGTH}" != "nolimit" ]; then
|
||||
reduced_value=$(cut -c1-"${MAX_LENGTH}" <<<"$reduced_value")
|
||||
fi
|
||||
# 1st : Remove trailing hypens
|
||||
sed -E 's/-*$//' <<<"$reduced_value"
|
||||
}
|
||||
|
||||
SLUG_VALUE=$(slug "$VALUE")
|
||||
SLUG_CS_VALUE=$(slug "$CS_VALUE")
|
||||
SLUG_URL_VALUE=$(slug_url "$VALUE")
|
||||
SLUG_URL_CS_VALUE=$(slug_url "$CS_VALUE")
|
||||
|
||||
if [ -f "$GITHUB_OUTPUT" ]; then
|
||||
{
|
||||
echo "value=${CS_VALUE}"
|
||||
echo "slug=${SLUG_VALUE}"
|
||||
echo "slug-cs=${SLUG_CS_VALUE}"
|
||||
echo "slug-url=${SLUG_URL_VALUE}"
|
||||
echo "slug-url-cs=${SLUG_URL_CS_VALUE}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "::set-output name=value::${CS_VALUE}"
|
||||
echo "::set-output name=slug::${SLUG_VALUE}"
|
||||
echo "::set-output name=slug-cs::${SLUG_CS_VALUE}"
|
||||
echo "::set-output name=slug-url::${SLUG_URL_VALUE}"
|
||||
echo "::set-output name=slug-url-cs::${SLUG_URL_CS_VALUE}"
|
||||
fi
|
||||
|
||||
if [ "${INPUT_PUBLISH_ENV}" == "true" ]; then
|
||||
{
|
||||
echo "${PREFIX}${KEY}=${CS_VALUE}"
|
||||
echo "${PREFIX}${KEY}_SLUG=${SLUG_VALUE}"
|
||||
echo "${PREFIX}${KEY}_SLUG_CS=${SLUG_CS_VALUE}"
|
||||
echo "${PREFIX}${KEY}_SLUG_URL=${SLUG_URL_VALUE}"
|
||||
echo "${PREFIX}${KEY}_SLUG_URL_CS=${SLUG_URL_CS_VALUE}"
|
||||
} >>"$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user