mirror of
https://github.com/rlespinasse/slugify-value.git
synced 2026-06-14 10:31:47 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38f26c3445 |
29
.github/workflows/slugify-value.yaml
vendored
29
.github/workflows/slugify-value.yaml
vendored
@@ -17,6 +17,7 @@ jobs:
|
|||||||
|
|
||||||
# Test 1
|
# Test 1
|
||||||
- name: Slugify key only
|
- name: Slugify key only
|
||||||
|
id: slugify-key-only
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
key: KEY_ONLY
|
key: KEY_ONLY
|
||||||
@@ -29,6 +30,11 @@ jobs:
|
|||||||
[[ "${{ env.KEY_ONLY_SLUG_CS }}" == "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 }}" == "key-only-test--value" ]]
|
||||||
[[ "${{ env.KEY_ONLY_SLUG_URL_CS }}" == "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
|
shell: bash
|
||||||
|
|
||||||
# Test 2
|
# Test 2
|
||||||
@@ -135,6 +141,29 @@ jobs:
|
|||||||
[[ "${{ steps.slugify-with-wrong-max-length.conclusion }}" == "success" ]]
|
[[ "${{ steps.slugify-with-wrong-max-length.conclusion }}" == "success" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
# Test 8
|
||||||
|
- name: Slugify key without env publication
|
||||||
|
id: slugify-key-without-env-publication
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
key: KEY_WITHTOUT_ENV_PUBLICATION
|
||||||
|
publish-env: false
|
||||||
|
env:
|
||||||
|
KEY_WITHTOUT_ENV_PUBLICATION: "Never gonna give you up"
|
||||||
|
- name: Validate // Slugify key without env publication
|
||||||
|
run: |
|
||||||
|
[[ -z "${{ env.KEY_WITHTOUT_ENV_PUBLICATION }}" ]]
|
||||||
|
[[ -z "${{ env.KEY_WITHTOUT_ENV_PUBLICATION_SLUG }}" ]]
|
||||||
|
[[ -z "${{ env.KEY_WITHTOUT_ENV_PUBLICATION_SLUG_CS }}" ]]
|
||||||
|
[[ -z "${{ env.KEY_WITHTOUT_ENV_PUBLICATION_SLUG_URL }}" ]]
|
||||||
|
[[ -z "${{ env.KEY_WITHTOUT_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:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
concurrency:
|
concurrency:
|
||||||
|
|||||||
@@ -114,6 +114,12 @@ This input is _Optional_.
|
|||||||
|
|
||||||
### `slug-maxlength`
|
### `slug-maxlength`
|
||||||
|
|
||||||
The value is a number or `nolimit` to reflect the length of the slug outputs
|
The value is a number or `nolimit` to reflect the length of the slug outputs.
|
||||||
|
|
||||||
This input is _Optional_. The default value is `63`.
|
This input is _Optional_. The default value is `63`.
|
||||||
|
|
||||||
|
### `publish-env`
|
||||||
|
|
||||||
|
In addition of the action output, the slug values are publish as environment variables.
|
||||||
|
|
||||||
|
This input is _Optional_. The default value is `true`.
|
||||||
|
|||||||
30
action.yml
30
action.yml
@@ -1,6 +1,9 @@
|
|||||||
name: "Slugify Value"
|
name: "Slugify Value"
|
||||||
description: "Github Action to slugify a value"
|
description: "Github Action to slugify a value"
|
||||||
author: "Romain Lespinasse"
|
author: "Romain Lespinasse"
|
||||||
|
branding:
|
||||||
|
icon: "crop"
|
||||||
|
color: "gray-dark"
|
||||||
inputs:
|
inputs:
|
||||||
key:
|
key:
|
||||||
description: "Environment variable that will hold the value and serve as prefix to slugified value"
|
description: "Environment variable that will hold the value and serve as prefix to slugified value"
|
||||||
@@ -16,16 +19,35 @@ inputs:
|
|||||||
description: "Max length of the slugified values"
|
description: "Max length of the slugified values"
|
||||||
default: "63"
|
default: "63"
|
||||||
required: true
|
required: true
|
||||||
branding:
|
publish-env:
|
||||||
icon: "crop"
|
description: "Publish slugs as environment variables"
|
||||||
color: "gray-dark"
|
default: "true"
|
||||||
|
required: true
|
||||||
|
outputs:
|
||||||
|
value:
|
||||||
|
description: "Value"
|
||||||
|
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:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
- run: $GITHUB_ACTION_PATH/slugify.sh
|
- id: slugify
|
||||||
|
run: $GITHUB_ACTION_PATH/slugify.sh
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
INPUT_KEY: ${{ inputs.key }}
|
INPUT_KEY: ${{ inputs.key }}
|
||||||
INPUT_VALUE: ${{ inputs.value }}
|
INPUT_VALUE: ${{ inputs.value }}
|
||||||
INPUT_PREFIX: ${{ inputs.prefix }}
|
INPUT_PREFIX: ${{ inputs.prefix }}
|
||||||
INPUT_SLUG_MAXLENGTH: ${{ inputs.slug-maxlength }}
|
INPUT_SLUG_MAXLENGTH: ${{ inputs.slug-maxlength }}
|
||||||
|
INPUT_PUBLISH_ENV: ${{ inputs.publish-env }}
|
||||||
|
|||||||
27
slugify.sh
27
slugify.sh
@@ -53,10 +53,23 @@ reduce() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
SLUG_VALUE=$(slug "$VALUE")
|
||||||
echo "${PREFIX}${KEY}=${CS_VALUE}"
|
SLUG_CS_VALUE=$(slug "$CS_VALUE")
|
||||||
echo "${PREFIX}${KEY}_SLUG=$(slug "$VALUE")"
|
SLUG_URL_VALUE=$(slug_url "$VALUE")
|
||||||
echo "${PREFIX}${KEY}_SLUG_CS=$(slug "$CS_VALUE")"
|
SLUG_URL_CS_VALUE=$(slug_url "$CS_VALUE")
|
||||||
echo "${PREFIX}${KEY}_SLUG_URL=$(slug_url "$VALUE")"
|
|
||||||
echo "${PREFIX}${KEY}_SLUG_URL_CS=$(slug_url "$CS_VALUE")"
|
echo "::set-output name=value::${CS_VALUE}"
|
||||||
} >>"$GITHUB_ENV"
|
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}"
|
||||||
|
|
||||||
|
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