mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-05-18 04:15:14 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88f3ee8f6f |
66
.github/workflows/github-slug-action.yml
vendored
66
.github/workflows/github-slug-action.yml
vendored
@@ -112,6 +112,71 @@ jobs:
|
||||
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
|
||||
shell: bash
|
||||
|
||||
os-testing-slug-maxlength:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Test 1
|
||||
- name: Using correct max length
|
||||
uses: ./
|
||||
with:
|
||||
prefix: "CML_"
|
||||
slug-maxlength: 1
|
||||
- name: Using correct max length // Validate that all slug variables are equals or under the slug-maxlength
|
||||
run: |
|
||||
env | grep "CML_" | grep "_SLUG" | cut -d"=" -f2 | while read -r value; do [ "$(echo "$value" | wc -m)" -le 2 ] ; done
|
||||
shell: bash
|
||||
|
||||
# Test 2
|
||||
- name: Using wrong max length
|
||||
id: using-wrong-max-length
|
||||
uses: ./
|
||||
with:
|
||||
prefix: "WML_"
|
||||
slug-maxlength: "wrong"
|
||||
continue-on-error: true
|
||||
- name: Using wrong max length // Validate that the action end with an error
|
||||
run: |
|
||||
[[ "$(env | grep "WML_" | grep "_SLUG" | wc -l)" -eq 0 ]]
|
||||
[[ "${{ steps.using-wrong-max-length.outcome }}" == "failure" ]]
|
||||
[[ "${{ steps.using-wrong-max-length.conclusion }}" == "success" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 3
|
||||
- name: Using empty max length
|
||||
id: using-empty-max-length
|
||||
uses: ./
|
||||
with:
|
||||
prefix: "EML_"
|
||||
slug-maxlength: ""
|
||||
continue-on-error: true
|
||||
- name: Using empty max length // Validate that the action end with an error
|
||||
run: |
|
||||
[[ "$(env | grep "EML_" | grep "_SLUG" | wc -l)" -eq 0 ]]
|
||||
[[ "${{ steps.using-empty-max-length.outcome }}" == "failure" ]]
|
||||
[[ "${{ steps.using-empty-max-length.conclusion }}" == "success" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 4
|
||||
- name: Using no limit on max length
|
||||
id: using-nolimit-max-length
|
||||
uses: ./
|
||||
with:
|
||||
prefix: "NLML_"
|
||||
slug-maxlength: "nolimit"
|
||||
- name: Using no limit on length // Validate that the action end with an error
|
||||
run: |
|
||||
[[ "$(env | grep "NLML_" | grep "_SLUG" | wc -l)" -gt 0 ]]
|
||||
[[ "${{ steps.using-nolimit-max-length.outcome }}" == "success" ]]
|
||||
[[ "${{ steps.using-nolimit-max-length.conclusion }}" == "success" ]]
|
||||
shell: bash
|
||||
|
||||
os-testing-without-checkout:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -144,6 +209,7 @@ jobs:
|
||||
group: release-${{ github.ref }}-${{ github.event_name }}
|
||||
needs:
|
||||
- os-testing
|
||||
- os-testing-slug-maxlength
|
||||
- os-testing-without-checkout
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
11
README.md
11
README.md
@@ -68,6 +68,15 @@ Or with a prefix
|
||||
prefix: CI_
|
||||
```
|
||||
|
||||
Or with another max length for slug values
|
||||
|
||||
```yaml
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v4
|
||||
with:
|
||||
slug-maxlength: 80 # use 'nolimit' to remove use of a max length
|
||||
```
|
||||
|
||||
Check for more [examples][examples] (OS usage, URL use, ...)
|
||||
|
||||
**Tip:** Use [Dependabot][dependabot] to maintain your `github-slug-action` version updated in your GitHub workflows.
|
||||
@@ -168,7 +177,7 @@ Download action repository 'rlespinasse/github-slug-action@GIT_REFERENCE'
|
||||
##[error]An action could not be found at the URI 'https://api.github.com/repos/rlespinasse/github-slug-action/tarball/GIT_REFERENCE'
|
||||
```
|
||||
|
||||
If the `GIT_REFERENCE` value is
|
||||
If the `GIT_REFERENCE` value is
|
||||
|
||||
- `v4.x` or after, the branch don't exists anymore following the [end-of-life for a branch](SECURITY.md#end-of-life-of-a-branch) security process.
|
||||
- `master`, the branch don't exists anymore, read more about it on the corresponding issue ([EOL issue][issue-15])
|
||||
|
||||
33
action.yml
33
action.yml
@@ -9,59 +9,76 @@ inputs:
|
||||
description: "Value to prepend to each generated variable"
|
||||
default: ""
|
||||
required: false
|
||||
slug-maxlength:
|
||||
description: "Max length of the slugified values"
|
||||
default: "63"
|
||||
required: true
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: rlespinasse/slugify-value@v1.1.0
|
||||
- run: $GITHUB_ACTION_PATH/preflight.sh
|
||||
shell: bash
|
||||
env:
|
||||
INPUT_SLUG_MAXLENGTH: ${{ inputs.slug-maxlength }}
|
||||
|
||||
- uses: rlespinasse/slugify-value@v1.2.0
|
||||
with:
|
||||
key: GITHUB_REPOSITORY
|
||||
value: ${{ github.repository }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
- uses: rlespinasse/slugify-value@v1.1.0
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- uses: rlespinasse/slugify-value@v1.2.0
|
||||
with:
|
||||
key: GITHUB_REF
|
||||
prefix: ${{ inputs.prefix }}
|
||||
- uses: rlespinasse/slugify-value@v1.1.0
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- uses: rlespinasse/slugify-value@v1.2.0
|
||||
with:
|
||||
key: GITHUB_HEAD_REF
|
||||
prefix: ${{ inputs.prefix }}
|
||||
- uses: rlespinasse/slugify-value@v1.1.0
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- uses: rlespinasse/slugify-value@v1.2.0
|
||||
with:
|
||||
key: GITHUB_BASE_REF
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
|
||||
# Specific values
|
||||
- uses: rlespinasse/slugify-value@v1.1.0
|
||||
- uses: rlespinasse/slugify-value@v1.2.0
|
||||
with:
|
||||
key: GITHUB_EVENT_REF
|
||||
value: ${{ github.event.ref }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
|
||||
# Calculated values
|
||||
- id: get-github-ref-name
|
||||
run: echo "::set-output name=github-ref-name::$(echo "${{ github.head_ref || github.ref }}" | cut -d/ -f3)"
|
||||
shell: bash
|
||||
- uses: rlespinasse/slugify-value@v1.1.0
|
||||
- uses: rlespinasse/slugify-value@v1.2.0
|
||||
with:
|
||||
key: GITHUB_REF_NAME
|
||||
value: ${{ steps.get-github-ref-name.outputs.github-ref-name }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- id: get-github-repository-owner-part
|
||||
run: echo "::set-output name=github-repository-owner-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f1)"
|
||||
shell: bash
|
||||
- uses: rlespinasse/slugify-value@v1.1.0
|
||||
- uses: rlespinasse/slugify-value@v1.2.0
|
||||
with:
|
||||
key: GITHUB_REPOSITORY_OWNER_PART
|
||||
value: ${{ steps.get-github-repository-owner-part.outputs.github-repository-owner-part }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- id: get-github-repository-name-part
|
||||
run: echo "::set-output name=github-repository-name-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f2)"
|
||||
shell: bash
|
||||
- uses: rlespinasse/slugify-value@v1.1.0
|
||||
- uses: rlespinasse/slugify-value@v1.2.0
|
||||
with:
|
||||
key: GITHUB_REPOSITORY_NAME_PART
|
||||
value: ${{ steps.get-github-repository-name-part.outputs.github-repository-name-part }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
|
||||
# Short
|
||||
- uses: rlespinasse/shortify-git-revision@v1.4.0
|
||||
|
||||
9
preflight.sh
Executable file
9
preflight.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "${INPUT_SLUG_MAXLENGTH}" ]; then
|
||||
echo "::error ::slug-maxlength cannot be empty"
|
||||
exit 1
|
||||
elif [ "${INPUT_SLUG_MAXLENGTH}" != "nolimit" ] && [ ! "${INPUT_SLUG_MAXLENGTH}" -eq "${INPUT_SLUG_MAXLENGTH}" ] 2>/dev/null; then
|
||||
echo "::error ::slug-maxlength must be a number or equals to 'nolimit'"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user