Compare commits

..

38 Commits

Author SHA1 Message Date
dependabot[bot]
955b5ba456 feat: bump actions/github-script from 6 to 7 (#157)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-11 04:15:50 +01:00
Romain Lespinasse
ba00826602 ci(check-variables): print a warning if a GITHUB_* variable from this action already exists (#155) 2025-03-08 01:11:51 +01:00
Romain Lespinasse
797666298f docs: improve warning on short auto sizing (#154) 2024-11-17 21:22:32 +01:00
Romain Lespinasse
56d132125c docs(references): add a new article in the french section (#152)
Signed-off-by: Romain Lespinasse <romain.lespinasse@gmail.com>
2024-11-10 05:21:04 +01:00
Romain Lespinasse
aba9f8db6e feat: use GITHUB_REF_POINT as variable for the branch name (#149)
BREAKING CHANGE: Change the behavior of GITHUB_REF_NAME to match the default GitHub Action behavior,
BREAKING CHANGE: Introduce GITHUB_REF_POINT as a replacement for GITHUB_REF_NAME to match this GitHub Action behavior in v4.
2024-11-06 00:16:25 +01:00
Romain Lespinasse
63a442f83b build: prepare v5.x branch (#148)
Signed-off-by: Romain Lespinasse <romain.lespinasse@gmail.com>
2024-11-01 10:11:33 +01:00
dependabot[bot]
c6c92fed42 ci: bump github/super-linter from 6 to 7 (#146)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-09-02 23:45:16 +02:00
Romain Lespinasse
7c4f489627 build: cleanup old npm packages from GitHub dependency graph
Signed-off-by: Romain Lespinasse <romain.lespinasse@gmail.com>
2024-07-16 08:54:31 +02:00
Romain Lespinasse
45c9d47db8 docs(security): update supported versions
Signed-off-by: Romain Lespinasse <romain.lespinasse@gmail.com>
2024-06-24 22:37:23 +02:00
dependabot[bot]
797d688647 feat: bump github/super-linter from 5 to 6 (#145)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-30 22:30:49 +02:00
Romain Lespinasse
55f5982579 ci(build): use personal token (#144) 2024-01-24 17:14:44 +01:00
Romain Lespinasse
5ee5b39fa5 build(dependabot): fix updates groups syntax (#143)
Signed-off-by: Romain Lespinasse <romain.lespinasse@gmail.com>
2024-01-04 22:26:25 +01:00
Romain Lespinasse
399f2aa780 build(dependabot): update slugify-value and shortify-git-revision as new features (#142)
Signed-off-by: Romain Lespinasse <romain.lespinasse@gmail.com>
2024-01-04 21:58:27 +01:00
dependabot[bot]
87a6de197b build(deps): bump the dependencies group with 1 update (#141) 2023-12-25 17:32:00 +01:00
Romain Lespinasse
6e13412dd5 build(dependabot): move to v2 configuration (#139) 2023-12-25 15:10:58 +01:00
Romain Lespinasse
00d4236bb3 docs(security): fix wrong markdown link
Signed-off-by: Romain Lespinasse <romain.lespinasse@gmail.com>
2023-10-24 15:55:43 +02:00
Romain Lespinasse
e5042e702f docs(security): simplify the end of life process 2023-10-20 12:34:43 +02:00
Romain Lespinasse
d1ca8ffbce ci(linter): setup super linter workflow 2023-06-11 11:34:00 +02:00
Romain Lespinasse
094dd7fdb3 docs(security): improve vulnerability reporting section
Signed-off-by: Romain Lespinasse <romain.lespinasse@gmail.com>
2023-03-14 19:49:15 +01:00
Romain Lespinasse
4bf56f04ea docs(readme): rework article/talk links
Signed-off-by: Romain Lespinasse <romain.lespinasse@gmail.com>
2023-02-28 09:23:48 +01:00
二丫讲梵
552f3c0362 docs(readme): add new link in the article section 2023-02-28 09:19:47 +01:00
Romain Lespinasse
102b1a064a fix: use github.head_ref env var as trusted input 2023-02-20 11:57:12 +01:00
Romain Lespinasse
a362e5fb42 feat: support GHES step output management 2022-10-31 19:55:46 +01:00
Nick Reynolds
b011e83cf8 fix: update dependencies to remove internal warnings
Update slugify-value to 1.3.3
Update shortify-git-revision to 1.5.1

Signed-off-by: Nick Reynolds <nickittynack@users.noreply.github.com>
2022-10-17 21:21:57 +02:00
Vin
00198f8992 fix: use environment file to manage outputs
Co-authored-by: Vin <vin@8sistemas.com>
Co-authored-by: Romain Lespinasse <romain.lespinasse@gmail.com>
2022-10-15 20:56:22 +02:00
Romain Lespinasse
9c3571fd3d feat: generate proper git tag 2022-10-02 22:52:40 +02:00
Romain Lespinasse
0141d9b38d fix: remove trailing hypen if any after cut 2022-06-16 19:55:01 +02:00
rlespinasse
33cd7a701d docs(README): improve the overwrite troubleshooting section 2022-04-16 19:25:44 +02:00
rlespinasse
2c5a627861 fix(GITHUB_REF_NAME): correctly fill the variable on pull request events 2022-04-16 19:25:44 +02:00
Romain Lespinasse
aa95092e35 docs: remove badges 2022-04-09 08:12:02 +02:00
rlespinasse
1615fcb48b fix: preserve dash groups 2022-04-08 23:48:02 +02:00
rlespinasse
812bd42f94 fix: remove underscore from URL-compliant slugs 2022-04-08 23:48:02 +02:00
Romain Lespinasse
6839855732 ci: rename workflow 2022-04-07 20:47:54 +02:00
rlespinasse
53459a86e2 ci: improve workflow 2022-03-24 12:59:58 +01:00
Romain Lespinasse
4177734b38 docs: cleanup 2022-03-24 08:14:21 +01:00
Romain Lespinasse
ad808ea8b2 fix: do not replace group of dashes with a single dash 2022-03-24 08:13:33 +01:00
rlespinasse
7a3b4c1766 fix: set short-length automatically when no checkout 2022-03-22 15:41:41 +01:00
rlespinasse
dbbe21b72b feat: add option to set a different short length than git defaults 2022-03-21 16:47:28 +01:00
20 changed files with 1049 additions and 607 deletions

View File

@@ -1,6 +0,0 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

27
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,27 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/.github/"
schedule:
interval: "weekly"
groups:
dependencies:
patterns:
- "*"
reviewers:
- "rlespinasse"
labels: [ ]
- package-ecosystem: "github-actions"
directory: "/"
commit-message:
prefix: "feat: "
schedule:
interval: "weekly"
groups:
dependencies:
patterns:
- "rlespinasse/slugify-value"
- "rlespinasse/shortify-git-revision"
reviewers:
- "rlespinasse"
labels: [ ]

139
.github/workflows/check-variables.yml vendored Normal file
View File

@@ -0,0 +1,139 @@
---
name: Compare GitHub Variables
on:
workflow_dispatch: # Manual trigger
schedule:
- cron: "0 0 * * 1" # Weekly on Monday at midnight
pull_request:
permissions: read-all
jobs:
compare-variables:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Load environment variables for testing
uses: rlespinasse/github-slug-action@v5
with:
prefix: TEST_
- name: Compare GitHub variables
id: compare
run: |
# Initialize arrays to store results
MISMATCHED_VARS=()
TEST_VALUES=()
ACTUAL_VALUES=()
# Get all environment variables
ALL_ENV=$(env)
# Extract TEST_GITHUB variables
TEST_VARS=$(echo "$ALL_ENV" | grep "^TEST_GITHUB_" | cut -d= -f1)
# Check for mismatches
for TEST_VAR in $TEST_VARS; do
# Get the corresponding GITHUB variable name
GITHUB_VAR=${TEST_VAR/TEST_GITHUB_/GITHUB_}
# Get the values
TEST_VALUE="${!TEST_VAR}"
# Check if the GITHUB variable exists
if [[ -n "${!GITHUB_VAR+x}" ]]; then
GITHUB_VALUE="${!GITHUB_VAR}"
# Compare values
if [[ "$TEST_VALUE" != "$GITHUB_VALUE" ]]; then
MISMATCHED_VARS+=("$TEST_VAR vs $GITHUB_VAR")
TEST_VALUES+=("$TEST_VALUE")
ACTUAL_VALUES+=("$GITHUB_VALUE")
echo "Mismatch found: $TEST_VAR=$TEST_VALUE, $GITHUB_VAR=$GITHUB_VALUE"
else
echo "Match: $TEST_VAR=$TEST_VALUE, $GITHUB_VAR=$GITHUB_VALUE"
fi
else
echo "Skipping $TEST_VAR as $GITHUB_VAR does not exist"
fi
done
# Set output for next steps
if [[ ${#MISMATCHED_VARS[@]} -gt 0 ]]; then
echo "has_mismatches=true" >>"$GITHUB_OUTPUT"
# Create a JSON array of mismatched variables for the issue
MISMATCHED_JSON=$(printf '"%s",' "${MISMATCHED_VARS[@]}" | sed 's/,$//')
MISMATCHED_JSON="[$MISMATCHED_JSON]"
echo "mismatched_vars=$MISMATCHED_JSON" >>"$GITHUB_OUTPUT"
# Create a JSON array of test values
TEST_JSON=$(printf '"%s",' "${TEST_VALUES[@]}" | sed 's/,$//')
TEST_JSON="[$TEST_JSON]"
echo "test_values=$TEST_JSON" >>"$GITHUB_OUTPUT"
# Create a JSON array of actual values
ACTUAL_JSON=$(printf '"%s",' "${ACTUAL_VALUES[@]}" | sed 's/,$//')
ACTUAL_JSON="[$ACTUAL_JSON]"
echo "actual_values=$ACTUAL_JSON" >>"$GITHUB_OUTPUT"
# Create summary table
{
echo "## GitHub Variable Mismatches";
echo "| Variable Pair | TEST Value | GITHUB Value |";
echo "| ------------- | ---------- | ------------ |";
} >>"$GITHUB_STEP_SUMMARY"
for i in "${!MISMATCHED_VARS[@]}"; do
echo "| ${MISMATCHED_VARS[$i]} | ${TEST_VALUES[$i]} | ${ACTUAL_VALUES[$i]} |" >>"$GITHUB_STEP_SUMMARY"
done
else
echo "has_mismatches=false" >>"$GITHUB_OUTPUT"
echo "## All GitHub Variables Match" >>"$GITHUB_STEP_SUMMARY"
echo "All action GITHUB_ variables match their official GITHUB_ counterparts." >>"$GITHUB_STEP_SUMMARY"
fi
shell: bash
- name: Create issue for mismatches
if: steps.compare.outputs.has_mismatches == 'true' && github.event_name != 'pull_request'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const mismatchedVars = JSON.parse('${{ steps.compare.outputs.mismatched_vars }}');
const testValues = JSON.parse('${{ steps.compare.outputs.test_values }}');
const actualValues = JSON.parse('${{ steps.compare.outputs.actual_values }}');
// Create table for issue body
let tableBody = '| Variable Pair | TEST Value | GITHUB Value |\n';
tableBody += '| ------------- | ---------- | ------------ |\n';
for (let i = 0; i < mismatchedVars.length; i++) {
tableBody += `| ${mismatchedVars[i]} | ${testValues[i]} | ${actualValues[i]} |\n`;
}
// Create the issue
const issueTitle = `GitHub Variable Mismatches Detected - ${new Date().toISOString().split('T')[0]}`;
const issueBody = `## GitHub Variable Mismatches Detected\n\nThe following mismatches were found between the action **GITHUB_** variables and their official **GITHUB_** counterparts:\n\n${tableBody}\n\nPlease review these discrepancies and update the test variables as needed.`;
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: issueTitle,
body: issueBody,
labels: ['bug']
});
console.log('Issue created for GitHub variable mismatches');
- name: Fail workflow if mismatches detected
if: steps.compare.outputs.has_mismatches == 'true' && github.event_name == 'pull_request'
run: |
echo "::error::GitHub variable mismatches detected! See the summary for details."
exit 1

View File

@@ -1,220 +0,0 @@
name: Github Slug Action testing
on: [push, pull_request]
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@v3
- name: Load using v3.x
uses: rlespinasse/github-slug-action@v3.x
- name: Load using v4.x with prefix
uses: ./
with:
prefix: V4_
- name: Validate // Partial variables
run: |
echo "repository owner : ${{ env.V4_GITHUB_REPOSITORY_OWNER_PART }}"
echo "repository name : ${{ env.V4_GITHUB_REPOSITORY_NAME_PART }}"
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART }}" ]]
shell: bash
- name: Validate // Slug variables
run: |
echo "repository : ${{ env.V4_GITHUB_REPOSITORY_SLUG }}"
echo "repository owner : ${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG }}"
echo "repository name : ${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG }}"
echo "ref : ${{ env.V4_GITHUB_REF_SLUG }}"
echo "head ref : ${{ env.V4_GITHUB_HEAD_REF_SLUG }}"
echo "base ref : ${{ env.V4_GITHUB_BASE_REF_SLUG }}"
echo "event ref : ${{ env.V4_GITHUB_EVENT_REF_SLUG }}"
[[ "${{ env.GITHUB_REPOSITORY_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG }}" ]]
[[ "${{ env.GITHUB_REF_SLUG }}" == "${{ env.V4_GITHUB_REF_SLUG }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG }}" ]]
shell: bash
- name: Validate // Slug variables (Case Sensitive)
run: |
echo "repository : ${{ env.V4_GITHUB_REPOSITORY_SLUG_CS }}"
echo "repository owner : ${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}"
echo "repository name : ${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}"
echo "ref : ${{ env.V4_GITHUB_REF_SLUG_CS }}"
echo "head ref : ${{ env.V4_GITHUB_HEAD_REF_SLUG_CS }}"
echo "base ref : ${{ env.V4_GITHUB_BASE_REF_SLUG_CS }}"
echo "event ref : ${{ env.V4_GITHUB_EVENT_REF_SLUG_CS }}"
[[ "${{ env.GITHUB_REPOSITORY_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_CS }}" ]]
shell: bash
- name: Validate // Slug URL variables
run: |
echo "repository : ${{ env.V4_GITHUB_REPOSITORY_SLUG_URL }}"
echo "repository owner : ${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}"
echo "repository name : ${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}"
echo "ref : ${{ env.V4_GITHUB_REF_SLUG_URL }}"
echo "head ref : ${{ env.V4_GITHUB_HEAD_REF_SLUG_URL }}"
echo "base ref : ${{ env.V4_GITHUB_BASE_REF_SLUG_URL }}"
echo "event ref : ${{ env.V4_GITHUB_EVENT_REF_SLUG_URL }}"
[[ "${{ env.GITHUB_REPOSITORY_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL }}" ]]
shell: bash
- name: Validate // Slug URL variables (Case Sensitive)
run: |
echo "repository : ${{ env.V4_GITHUB_REPOSITORY_SLUG_URL_CS }}"
echo "repository owner : ${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}"
echo "repository name : ${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}"
echo "ref : ${{ env.V4_GITHUB_REF_SLUG_URL_CS }}"
echo "head ref : ${{ env.V4_GITHUB_HEAD_REF_SLUG_URL_CS }}"
echo "base ref : ${{ env.V4_GITHUB_BASE_REF_SLUG_URL_CS }}"
echo "event ref : ${{ env.V4_GITHUB_EVENT_REF_SLUG_URL_CS }}"
[[ "${{ env.GITHUB_REPOSITORY_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL_CS }}" ]]
shell: bash
- name: Validate // Ref Name
run: |
echo "raw : ${{ env.V4_GITHUB_REF_NAME }}"
echo "slug : ${{ env.V4_GITHUB_REF_NAME_SLUG }}"
echo "slug url : ${{ env.V4_GITHUB_REF_NAME_SLUG_URL }}"
echo "slug (Case Sensitive) : ${{ env.V4_GITHUB_REF_NAME_SLUG_CS }}"
echo "slug url (Case Sensitive) : ${{ env.V4_GITHUB_REF_NAME_SLUG_URL_CS }}"
[[ "${{ env.GITHUB_REF_NAME }}" == "${{ env.V4_GITHUB_REF_NAME }}" ]]
[[ "${{ env.GITHUB_REF_NAME_SLUG }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG }}" ]]
[[ "${{ env.GITHUB_REF_NAME_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REF_NAME_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REF_NAME_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL_CS }}" ]]
shell: bash
- name: Validate // Short SHA variables
run: |
echo "sha : ${{ env.V4_GITHUB_SHA_SHORT }}"
echo "pull request sha : ${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
[[ "${{ env.GITHUB_SHA_SHORT }}" == "${{ env.V4_GITHUB_SHA_SHORT }}" ]]
[[ "${{ 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
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: this-action
ref: ${{ github.ref }}
- name: Load using v3.x
uses: rlespinasse/github-slug-action@v3.x
- name: Load using v4.x with prefix
uses: ./this-action
with:
prefix: V4_
- name: Validate // Short SHA variables
run: |
echo "sha : ${{ env.V4_GITHUB_SHA_SHORT }}"
echo "pull request sha : ${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
[[ "${{ env.GITHUB_SHA_SHORT }}" == "${{ env.V4_GITHUB_SHA_SHORT }}" ]]
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
shell: bash
release:
runs-on: ubuntu-latest
concurrency:
group: release-${{ github.ref }}-${{ github.event_name }}
needs:
- os-testing
- os-testing-slug-maxlength
- os-testing-without-checkout
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Release this GitHub Action
uses: rlespinasse/release-that@v1
with:
without-prefix: true

32
.github/workflows/linter.yml vendored Normal file
View File

@@ -0,0 +1,32 @@
---
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@v4
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: github/super-linter@v7
env:
VALIDATE_ALL_CODEBASE: false
VALIDATE_JSCPD: false
VALIDATE_JSON_PRETTIER: false
VALIDATE_MARKDOWN_PRETTIER: false
DEFAULT_BRANCH: v5.x
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -0,0 +1,402 @@
name: "[v5] Test and Release"
on: [push, pull_request]
permissions: read-all
jobs:
check-v4-compatibility:
name: "Check v4 compatibility"
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load this action from HEAD
uses: ./
- name: Load using v4
uses: rlespinasse/github-slug-action@v4
with:
prefix: V4_
- name: Validate // Partial variables
run: |
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART }}" ]]
shell: bash
- name: Validate // Slug variables
run: |
[[ "${{ env.GITHUB_REPOSITORY_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG }}" ]]
[[ "${{ env.GITHUB_REF_SLUG }}" == "${{ env.V4_GITHUB_REF_SLUG }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG }}" ]]
shell: bash
- name: Validate // Slug variables (Case Sensitive)
run: |
[[ "${{ env.GITHUB_REPOSITORY_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_CS }}" ]]
shell: bash
- name: Validate // Slug URL variables
run: |
[[ "${{ env.GITHUB_REPOSITORY_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL }}" ]]
shell: bash
- name: Validate // Slug URL variables (Case Sensitive)
run: |
[[ "${{ env.GITHUB_REPOSITORY_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_HEAD_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_URL_CS }}" ]]
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL_CS }}" ]]
shell: bash
- name: Validate // Ref Point
run: |
[[ "${{ env.GITHUB_REF_POINT }}" == "${{ env.V4_GITHUB_REF_NAME }}" ]]
[[ "${{ env.GITHUB_REF_POINT_SLUG }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG }}" ]]
[[ "${{ env.GITHUB_REF_POINT_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL }}" ]]
[[ "${{ env.GITHUB_REF_POINT_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_CS }}" ]]
[[ "${{ env.GITHUB_REF_POINT_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL_CS }}" ]]
shell: bash
- name: Validate // Short SHA variables
run: |
[[ "${{ env.GITHUB_SHA_SHORT }}" == "${{ env.V4_GITHUB_SHA_SHORT }}" ]]
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
shell: bash
check-v4-compatibility-without-checkout:
name: "Check v4 compatibility (without checkout)"
needs:
- check-v4-compatibility
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: this-action
ref: ${{ github.ref }}
- name: Load this action from HEAD
uses: ./this-action
- name: Load using v4
uses: rlespinasse/github-slug-action@v4
with:
prefix: V4_
- name: Validate // Short SHA variables
run: |
[[ "${{ env.GITHUB_SHA_SHORT }}" == "${{ env.V4_GITHUB_SHA_SHORT }}" ]]
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
shell: bash
display:
name: "Display produced variables"
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Load this action from HEAD
uses: ./
- name: Partial variables
run: |
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART }}"
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART }}"
shell: bash
- name: Slug variables
run: |
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}"
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}"
echo "ref : ${{ env.GITHUB_REF_SLUG }}"
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG }}"
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
shell: bash
- name: Slug variables (Case Sensitive)
run: |
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_CS }}"
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}"
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}"
echo "ref : ${{ env.GITHUB_REF_SLUG_CS }}"
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_CS }}"
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_CS }}"
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_CS }}"
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_CS }}"
shell: bash
- name: Slug URL variables
run: |
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}"
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}"
echo "ref : ${{ env.GITHUB_REF_SLUG_URL }}"
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_URL }}"
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
shell: bash
- name: Slug URL variables (Case Sensitive)
run: |
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL_CS }}"
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}"
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}"
echo "ref : ${{ env.GITHUB_REF_SLUG_URL_CS }}"
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_URL_CS }}"
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL_CS }}"
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}"
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}"
shell: bash
- name: Ref Point
run: |
echo "raw : ${{ env.GITHUB_REF_POINT }}"
echo "slug : ${{ env.GITHUB_REF_POINT_SLUG }}"
echo "slug url : ${{ env.GITHUB_REF_POINT_SLUG_URL }}"
echo "slug (Case Sensitive) : ${{ env.GITHUB_REF_POINT_SLUG_CS }}"
echo "slug url (Case Sensitive) : ${{ env.GITHUB_REF_POINT_SLUG_URL_CS }}"
shell: bash
- name: Short SHA variables
run: |
echo "sha : ${{ env.GITHUB_SHA_SHORT }}"
echo "pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
shell: bash
display-without-checkout:
name: "Display produced variables (without checkout)"
needs:
- display
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: this-action
ref: ${{ github.ref }}
- name: Load this action from HEAD
uses: ./this-action
- name: Short SHA variables
run: |
echo "sha : ${{ env.GITHUB_SHA_SHORT }}"
echo "pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
shell: bash
input-short-length:
name: "Input 'short-length'"
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Test 1
- name: Using correct short length
uses: ./
with:
prefix: "CSL_"
short-length: 4
- name: Using correct length // Validate that all short variables lengths are equals to short-length
run: |
env | grep "CSL_" | grep "_SHORT" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 5 ] ; done
shell: bash
# Test 2
- name: Using wrong short length
id: using-wrong-short-length
uses: ./
with:
prefix: "WSL_"
short-length: "wrong"
continue-on-error: true
- name: Using wrong short length // Validate that the action end with an error
run: |
[[ "$(env | grep "WSL_" | grep "_SHORT" -c)" -eq 0 ]]
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
shell: bash
input-short-length-without-checkout:
name: "Input 'short-length' (without checkout)"
needs:
- input-short-length
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: this-action
ref: ${{ github.ref }}
# Test 1
- name: Using correct short length
uses: ./this-action
with:
prefix: "CSL_"
short-length: 4
- name: Using correct length // Validate that all short variables lengths are equals to short-length
run: |
env | grep "CSL_" | grep "_SHORT" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 5 ] ; done
shell: bash
# Test 2
- name: Using empty short length
id: using-empty-short-length
uses: ./this-action
with:
prefix: "ESL_"
continue-on-error: true
- name: Using empty short length // Validate that the action don't end with an error
run: |
[[ "$(env | grep "ESL_" | grep "_SHORT" -c)" -gt 0 ]]
[[ "${{ steps.using-empty-short-length.outcome }}" == "success" ]]
[[ "${{ steps.using-empty-short-length.conclusion }}" == "success" ]]
shell: bash
# Test 3
- name: Using wrong short length
id: using-wrong-short-length
uses: ./this-action
with:
prefix: "WSL_"
short-length: "wrong"
continue-on-error: true
- name: Using wrong short length // Validate that the action end with an error
run: |
[[ "$(env | grep "WSL_" | grep "_SHORT" -c)" -eq 0 ]]
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
shell: bash
input-slug-maxlength:
name: "Input 'slug-maxlength'"
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
# Test 1
- name: Using correct slug max length
uses: ./
with:
prefix: "CML_"
slug-maxlength: 1
- name: Using correct max length // Validate that all slug variables lengths are equals or under the slug-maxlength
run: |
env | grep "CML_" | grep "_SLUG" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 2 ] ; done
shell: bash
# Test 2
- name: Using wrong slug max length
id: using-wrong-slug-max-length
uses: ./
with:
prefix: "WML_"
slug-maxlength: "wrong"
continue-on-error: true
- name: Using wrong slug max length // Validate that the action end with an error
run: |
[[ "$(env | grep "WML_" | grep "_SLUG" -c)" -eq 0 ]]
[[ "${{ steps.using-wrong-slug-max-length.outcome }}" == "failure" ]]
[[ "${{ steps.using-wrong-slug-max-length.conclusion }}" == "success" ]]
shell: bash
# Test 3
- name: Using empty slug max length
id: using-empty-slug-max-length
uses: ./
with:
prefix: "EML_"
slug-maxlength: ""
continue-on-error: true
- name: Using empty slug max length // Validate that the action end with an error
run: |
[[ "$(env | grep "EML_" | grep "_SLUG" -c)" -eq 0 ]]
[[ "${{ steps.using-empty-slug-max-length.outcome }}" == "failure" ]]
[[ "${{ steps.using-empty-slug-max-length.conclusion }}" == "success" ]]
shell: bash
# Test 4
- name: Using no limit on slug max length
id: using-nolimit-slug-max-length
uses: ./
with:
prefix: "NLML_"
slug-maxlength: "nolimit"
- name: Using no limit on slug max length // Validate that the action end with an error
run: |
[[ "$(env | grep "NLML_" | grep "_SLUG" -c)" -gt 0 ]]
[[ "${{ steps.using-nolimit-slug-max-length.outcome }}" == "success" ]]
[[ "${{ steps.using-nolimit-slug-max-length.conclusion }}" == "success" ]]
shell: bash
release:
runs-on: ubuntu-latest
permissions:
contents: write
issues: write
id-token: write
packages: write
concurrency:
group: release-${{ github.ref }}-${{ github.event_name }}
needs:
- display-without-checkout
- input-short-length-without-checkout
- input-slug-maxlength
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Release this GitHub Action
uses: rlespinasse/release-that@v1
with:
github-token: ${{ secrets.GH_TOKEN }}

View File

@@ -1,79 +0,0 @@
# [3.6.0](http://github.com/rlespinasse/github-slug-action/compare/3.5.1...3.6.0) (2021-09-15)
### Features
* add GITHUB_REF_NAME env var ([12a7510](http://github.com/rlespinasse/github-slug-action/commit/12a75106304d45442301df66d3ba38e1ac002649))
## [3.5.1](http://github.com/rlespinasse/github-slug-action/compare/3.5.0...3.5.1) (2021-03-31)
### Bug Fixes
* update dist files ([e6c550f](http://github.com/rlespinasse/github-slug-action/commit/e6c550f88ccca52a82675b89186b6b72864f087c))
# [3.5.0](http://github.com/rlespinasse/github-slug-action/compare/3.4.0...3.5.0) (2021-03-30)
### Features
* allow underscore in slug values ([475d293](http://github.com/rlespinasse/github-slug-action/commit/475d293680b998a3315846828329f05bfff4ac9c))
# [3.4.0](http://github.com/rlespinasse/github-slug-action/compare/3.3.0...3.4.0) (2021-03-02)
### Features
* add _CS suffix to keep value case-sensitive ([6c93fcb](http://github.com/rlespinasse/github-slug-action/commit/6c93fcbf53da9c6415bd7f5e37579b488f34339e))
# [3.3.0](http://github.com/rlespinasse/github-slug-action/compare/3.2.0...3.3.0) (2021-01-25)
### Bug Fixes
* support pull-request for slug and slug url ([78985f8](http://github.com/rlespinasse/github-slug-action/commit/78985f84eca97ef1c5262e85e8a73a277494c4ed))
### Features
* support partial GITHUB_REPOSITORY ([75ce03b](http://github.com/rlespinasse/github-slug-action/commit/75ce03b6a055a3be9d936a3a99c51038bd72298c))
# [3.2.0](http://github.com/rlespinasse/github-slug-action/compare/3.1.0...3.2.0) (2021-01-12)
### Features
* expose GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT ([5b9fe60](http://github.com/rlespinasse/github-slug-action/commit/5b9fe6015d2facc71c81d53bf3b08f04e0f3f743))
# [3.1.0](http://github.com/rlespinasse/github-slug-action/compare/3.0.0...3.1.0) (2020-11-01)
### Features
* **action:** improve marketplace information ([3cddc4f](http://github.com/rlespinasse/github-slug-action/commit/3cddc4f12d7a6fdbb8b1221dc02a2c64670e54bf))
# [3.0.0](http://github.com/rlespinasse/github-slug-action/compare/2.1.0...3.0.0) (2020-10-26)
### Bug Fixes
* upgrade actions core due to CVE fix ([d0549c1](http://github.com/rlespinasse/github-slug-action/commit/d0549c1f85ab9567b439f9d660b01ce1142b9fbe))
### Features
* add support for windows and macos jobs ([13c2f38](http://github.com/rlespinasse/github-slug-action/commit/13c2f38dad5f32529f37c25736412b1e4cf687fe))
### BREAKING CHANGES
* The action implementation move from container action to node.js action
Co-authored-by: Romain Lespinasse <romain.lespinasse@gmail.com>
# [2.1.0](http://github.com/rlespinasse/github-slug-action/compare/2.0.0...2.1.0) (2020-07-28)
### Features
* expose slug variables for github.event.ref ([5a334a8](http://github.com/rlespinasse/github-slug-action/commit/5a334a8573fc27451af5b2a6ee175d8e11579e10))

310
README.md
View File

@@ -1,27 +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.
## Table of Contents
- [GitHub Slug action](#github-slug-action)
- [Table of Contents](#table-of-contents)
- [Overview](#overview)
- [Use this action](#use-this-action)
- [Available Environment variables](#available-environment-variables)
- [Enhanced variables](#enhanced-variables)
- [Partial variables](#partial-variables)
- [Slug variables](#slug-variables)
- [Slug URL variables](#slug-url-variables)
- [Short variables](#short-variables)
- [Troubleshooting](#troubleshooting)
- [One of the environment variables doesn't work as intended](#one-of-the-environment-variables-doesnt-work-as-intended)
- [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)
This GitHub Action will expose the slug/short values of [some GitHub environment variables][default-environment-variables] inside your GitHub workflow.
## Overview
@@ -29,144 +8,217 @@ 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>
<p>
### Others Slug-ish variables are available
- `SLUG_URL` on a variable to have a `slug` variable compliant to be used in an URL
- Like `SLUG` but `.` is also replaced by `-`
- `SHORT` on a variable will limit the string size to ~8 characters
- `SLUG_URL` on a variable to have a `slug` variable compliant to be used in a URL
- Like `SLUG` but `.`, and `_` are also replaced by `-`
- `SHORT` on a variable will limit the string size to [~8 characters](#with-another-length-for-short-values)
- Useful for _sha_ value
- `<KEY>_PART` on a variable will give a part of a variable defined by a key
- Like `GITHUB_REPOSITORY_OWNER_PART` for the owner part of `GITHUB_REPOSITORY`
- `<VAR>_CS` on others variables to keep the value case-sensitive
- Like `GITHUB_REF_SLUG_CS`
</p>
</details>
## Installation
Additional enhanced environment variables can be compute to help you around GitHub environment variables.
## Use this action
Add this in your workflow
Add this step to your workflow
```yaml
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
steps:
- name: Inject enhanced GitHub environment variables
uses: rlespinasse/github-slug-action@v5
```
Or with a prefix
> [!CAUTION]
> Use [Dependabot][dependabot] to maintain your `github-slug-action` version updated in your GitHub workflows.
## Configuration Options
> [!TIP]
> Check for more [examples][examples] (OS usage, URL use, ...)
### With a prefix
```yaml
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v4
with:
prefix: CI_
steps:
- name: Inject enhanced GitHub environment variables
uses: rlespinasse/github-slug-action@v5
with:
prefix: CI_
```
Or with another max length for slug values
### 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
steps:
- name: Inject enhanced GitHub environment variables
uses: rlespinasse/github-slug-action@v5
with:
slug-maxlength: 80 # Use 'nolimit' to remove use of a max length (Default to 63)
```
Check for more [examples][examples] (OS usage, URL use, ...)
### With another length for short values
**Tip:** Use [Dependabot][dependabot] to maintain your `github-slug-action` version updated in your GitHub workflows.
```yaml
steps:
- name: Inject enhanced GitHub environment variables
uses: rlespinasse/github-slug-action@v5
with:
short-length: 7 # By default it's up to Git to decide, use 8 to have the v3.x behaviour
```
The length of a short sha depends of the size of **your repository** and can differ over time :
- set `7` to keep the `small repository` behaviour,
- set `8` to reproduce `v3` behaviour,
- set `4` as the minimum length possible.
> [!WARNING]
> If you leave it empty, you need to checkout the source first in order to let Git decide the size by itself by using [`git rev-parse`][git-revparse] behaviour.
>
> The default is the effective value of the [core.abbrev][git-core-abbrev] configuration variable.
## Available Environment variables
**Note**: If you don't find what you search for, read more about [available `GitHub` variables](docs/github-variables.md), and propose a [new custom variable][custom-variable].
> [!TIP]
> If you don't find what you search for
>
> - Read more about [available `GitHub` variables](docs/github-variables.md), and propose a [new custom variable][custom-variable].
> - Use your own variable with [slugify-value][slugify-value], or [shortify-git-revision][shortify-git-revision] for git reference.
### Enhanced variables
- `GITHUB_REF_NAME` will contains the reference name (branch or tag)
- `GITHUB_REF_POINT` will contains the reference name (branch or tag)
- based on `GITHUB_HEAD_REF` in a [`pull-request*`][webhooks-and-events] event context,
- based on `GITHUB_REF` in others event context.
- based on `GITHUB_REF_NAME` in others event context.
**NOTE:** All enhanced variables are available in all **slug** formats.
> [!NOTE]
> All enhanced variables are available in all **slug** formats.
### Partial variables
| Variable | Partial version of | Description |
| -------------------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------ |
| [GITHUB_REPOSITORY_OWNER_PART](docs/partial-variables.md#github_repository_owner_part) | GITHUB_REPOSITORY | The Owner part of GITHUB_REPOSITORY variable |
| [GITHUB_REPOSITORY_NAME_PART](docs/partial-variables.md#github_repository_name_part) | GITHUB_REPOSITORY | The Repository name part of GITHUB_REPOSITORY variable |
| Variable | Description |
| -------- | ----------- |
| [GITHUB_REPOSITORY_OWNER_PART](docs/partial-variables.md#github_repository_owner_part) | The Owner part of GITHUB_REPOSITORY variable |
| [GITHUB_REPOSITORY_NAME_PART](docs/partial-variables.md#github_repository_name_part) | The Repository name part of GITHUB_REPOSITORY variable |
### Slug variables
**NOTE:** `_CS` suffix available
> [!TIP]
> Available in standard and case-sensitive (`_CS`) versions.
| Variable | Slug version of | Description |
| ------------------------------------------------------------------------------------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| [GITHUB_REPOSITORY_SLUG](docs/slug-variables.md#github_repository_slug) | GITHUB_REPOSITORY | The owner and repository name. |
| [GITHUB_REPOSITORY<br>_OWNER_PART_SLUG](docs/slug-variables.md#github_repository_owner_part_slug) | GITHUB_REPOSITORY_OWNER_PART | The owner name. |
| [GITHUB_REPOSITORY<br>_NAME_PART_SLUG](docs/slug-variables.md#github_repository_name_part_slug) | GITHUB_REPOSITORY_NAME_PART | The repository name. |
| [GITHUB_REF_SLUG](docs/slug-variables.md#github_ref_slug) | GITHUB_REF | The branch or tag ref that triggered the workflow. |
| [GITHUB_HEAD_REF_SLUG](docs/slug-variables.md#github_head_ref_slug) | GITHUB_HEAD_REF | The branch of the head repository.<br>Only set for [pull-request][event-pull-request] event and forked repositories. |
| [GITHUB_BASE_REF_SLUG](docs/slug-variables.md#github_base_ref_slug) | GITHUB_BASE_REF | The branch of the base repository.<br>Only set for [pull-request][event-pull-request] event and forked repositories. |
| [GITHUB_EVENT_REF_SLUG](docs/slug-variables.md#github_event_ref_slug) | _github.event.ref_ | <br>Only set for [following webhook events][webhooks-and-events]<ul><li>`create`</li><li>`delete`</li></ul> |
| Variable | Description |
| -------- | ----------- |
| [GITHUB_REPOSITORY_SLUG](docs/slug-variables.md#github_repository_slug) | The owner and repository name. |
| [GITHUB_REPOSITORY_OWNER_PART_SLUG](docs/slug-variables.md#github_repository_owner_part_slug) | The owner name. |
| [GITHUB_REPOSITORY_NAME_PART_SLUG](docs/slug-variables.md#github_repository_name_part_slug) | The repository name. |
| [GITHUB_REF_SLUG](docs/slug-variables.md#github_ref_slug) | The branch or tag ref that triggered the workflow. |
| [GITHUB_REF_NAME_SLUG](docs/slug-variables.md#github_ref_name_slug) | This value matches the branch or tag name shown on GitHub. |
| [GITHUB_HEAD_REF_SLUG](docs/slug-variables.md#github_head_ref_slug) | The branch of the head repository. |
| [GITHUB_BASE_REF_SLUG](docs/slug-variables.md#github_base_ref_slug) | The branch of the base repository. |
| [GITHUB_EVENT_REF_SLUG](docs/slug-variables.md#github_event_ref_slug) | The Git reference resource associated to triggered webhook. |
### Slug URL variables
### URL-Safe Slug variables
**NOTE:** `_CS` suffix available
Same as slug variables but URL-compliant
| Variable | Slug URL version of | Description |
| --------------------------------------------------------------------------------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| [GITHUB_REPOSITORY_SLUG_URL](docs/slug-url-variables.md#github_repository_slug_url) | GITHUB_REPOSITORY | The owner and repository name. |
| [GITHUB_REPOSITORY<br>_OWNER_PART_SLUG_URL](docs/slug-variables.md#github_repository_owner_part_slug_url) | GITHUB_REPOSITORY_OWNER_PART | The owner name. |
| [GITHUB_REPOSITORY<br>_NAME_PART_SLUG_URL](docs/slug-variables.md#github_repository_name_part_slug_url) | GITHUB_REPOSITORY_NAME_PART | The repository name. |
| [GITHUB_REF_SLUG_URL](docs/slug-url-variables.md#github_ref_slug_url) | GITHUB_REF | The branch or tag ref that triggered the workflow. |
| [GITHUB_HEAD_REF_SLUG_URL](docs/slug-url-variables.md#github_head_ref_slug_url) | GITHUB_HEAD_REF | The branch of the head repository.<br>Only set for [pull-request][webhooks-and-events] event and forked repositories. |
| [GITHUB_BASE_REF_SLUG_URL](docs/slug-url-variables.md#github_base_ref_slug_url) | GITHUB_BASE_REF | The branch of the base repository.<br>Only set for [pull-request][webhooks-and-events] event and forked repositories. |
| [GITHUB_EVENT_REF_SLUG_URL](docs/slug-url-variables.md#github_event_ref_slug_url) | _github.event.ref_ | <br>Only set for [following webhook events][webhooks-and-events]<ul><li>`create`</li><li>`delete`</li></ul> |
> [!TIP]
> Available in standard and case-sensitive (`_CS`) versions.
| Variable | Description |
| -------- | ----------- |
| [GITHUB_REPOSITORY_SLUG_URL](docs/slug-url-variables.md#github_repository_slug_url) | The owner and repository name. |
| [GITHUB_REPOSITORY_OWNER_PART_SLUG_URL](docs/slug-variables.md#github_repository_owner_part_slug_url) | The owner name. |
| [GITHUB_REPOSITORY_NAME_PART_SLUG_URL](docs/slug-variables.md#github_repository_name_part_slug_url) | The repository name. |
| [GITHUB_REF_SLUG_URL](docs/slug-url-variables.md#github_ref_slug_url) | The branch or tag ref that triggered the workflow. |
| [GITHUB_REF_NAME_SLUG_URL](docs/slug-url-variables.md#github_ref_slug_url) | This value matches the branch or tag name shown on GitHub. |
| [GITHUB_HEAD_REF_SLUG_URL](docs/slug-url-variables.md#github_head_ref_slug_url) | The branch of the head repository. |
| [GITHUB_BASE_REF_SLUG_URL](docs/slug-url-variables.md#github_base_ref_slug_url) | The branch of the base repository. |
| [GITHUB_EVENT_REF_SLUG_URL](docs/slug-url-variables.md#github_event_ref_slug_url) | The Git reference resource associated to triggered webhook. |
### Short variables
| Variable | Short version of | Description |
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [GITHUB_SHA_SHORT](docs/short-variables.md#github_sha_short) | GITHUB_SHA | The commit SHA that triggered the workflow. |
| [GITHUB_EVENT<br>_PULL_REQUEST<br>_HEAD_SHA_SHORT](docs/short-variables.md#github_event_pull_request_head_sha_short) | _github.event<br>.pull_request<br>.head.sha_ | The commit SHA on pull request that trigger workflow.<br>Only set for [following webhook events][webhooks-and-events]<ul><li>`pull_request`</li><li>`pull_request_review`</li><li>`pull_request_review_comment`</li><li>`pull_request_target`</li></ul> |
| Variable | Description |
| -------- | ----------- |
| [GITHUB_SHA_SHORT](docs/short-variables.md#github_sha_short) | The commit SHA that triggered the workflow. |
| [GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT](docs/short-variables.md#github_event_pull_request_head_sha_short) | The commit SHA on pull request that trigger workflow. |
## Migration from previous versions
### v4 to v5
The **GITHUB_REF_NAME SLUG/SLUG_URL** variables doesn't work the same way as before
> [!TIP]
> If you use `v5` or related versions, you need to use `GITHUB_REF_POINT` instead of `GITHUB_REF_NAME` to get the behaviour of the `v4` action.
Before `v5`, the behaviour was the same as the GitHub one except on `pull_request*` workflows ([Ready the full story][issue-104]).
- `${{ env.GITHUB_REF_NAME }}` will serve the behaviour of this action,
- `$GITHUB_REF_NAME` will serve the behaviour of GitHub Action.
On `pull_request*` workflows, the content will be `<PR-number>/merge` instead of the branch name.
So you need to use `GITHUB_REF_POINT` instead
```yaml
steps:
- name: Inject enhanced GitHub environment variables
uses: rlespinasse/github-slug-action@v5
- run: |
echo "Branch Name: ${GITHUB_REF_POINT}"
shell: bash
```
Then `${{ env.GITHUB_REF_POINT }}`, and `$GITHUB_REF_POINT` will serve the behaviour of this action.
And `${{ env.GITHUB_REF_NAME }}`, and `$GITHUB_REF_NAME` will serve the behaviour of GitHub Action.
### v3 to v4
Since `v4`, it's Git who manage the short variables by using [`git rev-parse`][git-revparse] behaviour.
The length of a short sha depends of the size of **your repository** and can differ over time.
To manage that moving length, you can use `short-length` input
- set `7` to reproduce `small repository` behaviour
- set `8` to reproduce `v3` behaviour
> [!WARNING]
> The minimum length is 4, the default is the effective value of the [core.abbrev][git-core-abbrev] configuration variable.
So to reproduce previous behaviour, use
```yaml
steps:
- name: Inject enhanced GitHub environment variables
uses: rlespinasse/github-slug-action@v5
with:
short-length: 8 # Same as v3 and before
```
## Troubleshooting
### 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.
> [!WARNING]
> When you set a custom environment variable, you [cannot use any of the default environment variable names][naming-conventions]. 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 behaviour 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.
```yaml
name: Test
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: echo ${GITHUB_REF}
# print "refs/heads/v4.x"
- run: echo "GITHUB_REF=one_value" >> "$GITHUB_ENV"
- run: echo ${GITHUB_REF}
# print "refs/heads/v4.x"
- run: echo "GITHUB_REF_SLUG=another_value" >> "$GITHUB_ENV"
- run: echo ${GITHUB_REF_SLUG}
# print "another_value"
```
- `${{ env.GITHUB_AWESOME_VARIABLE }}` will serve the behaviour of this action,
- `$GITHUB_AWESOME_VARIABLE` will serve the behaviour of GitHub Action.
</p>
</details>
Otherwise the two expression will serve the behaviour of this action.
This will not occurs if you use the `prefix` input to avoid the issue.
> [!IMPORTANT]
> If detected, the maintainers of this action will choose the best course of action depending of the impact.
### An action could not be found at the URI
@@ -182,31 +234,49 @@ 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])
Please, use the current major tag `v4` or a version tag (see [releases pages][releases]) in order to fix your workflow.
Please, use the current major tag `v5` or a version tag (see [releases pages][releases]) in order to fix your workflow.
## Thanks for talking about us
- [Mettre en place une CI/CD Angular avec GitHub Actions & Netlify][article-1] (in french :fr:)
- [Github Actions : enfin des pipelines accessibles aux développeurs][talk-1] (in french :fr:)
In English :gb:
- [Action spotlight by Michael Heap][article-2]
- The next one is you. _Don't hesitate to add youself to this list._
- [Serverless Deploy Previews on GitHub Actions][article-3]
- [Let's Build a Continuous Delivery and Branching Process with GitHub Actions, Vercel and Heroku][article-4]
[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
In French :fr:
[actions]: https://github.com/rlespinasse/github-slug-action/actions
[license]: https://github.com/rlespinasse/github-slug-action/blob/v4.x/LICENSE
[examples]: https://github.com/rlespinasse/github-slug-action/tree/v4.x/examples
- [Mettre en place une CI/CD Angular avec GitHub Actions & Netlify][article-1]
- [GitHub Actions : enfin des pipelines accessibles aux développeurs][talk-1]
[GitHub-slug-action : 5 ans d'open source pour cette GitHub Action essentielle au CI/CD][article-6]
In Chinese :cn:
- [利用github-slug-action暴漏GitHub Action上下文中的关键变量][article-5]
> The next one is you. _Don't hesitate to add youself to one of these lists._
[examples]: https://github.com/rlespinasse/github-slug-action/tree/v5.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
[slugify-value]: https://github.com/rlespinasse/slugify-value
[shortify-git-revision]: https://github.com/rlespinasse/shortify-git-revision
[git-revparse]: https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---shortlength
[git-core-abbrev]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreabbrev
[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
[article-1]: https://esensconsulting.medium.com/mettre-en-place-une-ci-cd-angular-avec-github-actions-netlify-ca0b59b99ed8
[article-2]: https://michaelheap.com/github-slug-action/
[talk-1]: https://www.youtube.com/watch?v=RHnTJBwcE98
[article-3]: https://barstool.engineering/serverless-deploy-previews-on-github-actions/
[article-4]: https://javascript.plainenglish.io/lets-build-a-continuous-delivery-and-branching-process-c27dae09f0b6
[article-5]: https://eryajf.github.io/HowToStartOpenSource/views/03-github-tips/10-Use-github-slug-action-to-leak-key-variables-in-the-Github-Action-context.html
[article-6]: https://www.sfeir.dev/5-ans-de-github-slug-action-une-aventure-open-source/
[talk-1]: https://www.youtube.com/watch?v=F5mBDmOQcvE

View File

@@ -2,34 +2,26 @@
## Supported Versions and Branches
We only support 2 major versions for security patches
| Version | Supported | End of Support | Branch | Specific Tags |
| ------- | ------------------ | -------------- | ------ | ------------- |
| 5.x | :white_check_mark: | | v5.x | v5 |
| 4.x | :white_check_mark: | 2025-01-31 | v4.x | v4 |
| 3.x | :x: | 2024-01-31 | | v3.x, v3 |
| 2.x | :x: | 2021-04-05 | | v2.x, 2.2.0 |
| 1.x | :x: | 2021-04-05 | | v1.1.x, 1.2.0 |
| 1.0.x | :x: | 2019-11-07 | | 1.0.2 |
| Version | Branch | Supported | Specific Tags |
| ------- | ------ | ------------------ | ------------- |
| 4.x | v4.x | :white_check_mark: | v4 |
| 3.x | v3.x | :white_check_mark: | |
| < 2.x | | :x: | v2.x, v1.1.x |
A GitHub repository can used one of the available branches as action inside its workflows.
A GitHub repository can use one of the available branches as an action inside its workflows.
### End of Life of a branch
When a branch is not supported anymore, the following process occurs
Since `2023-10-20`, when a new major version is released,
- Since `v4.x` branch, the branch will be deleted 2 major versions after
- So `v4.x` branch will be deleted when `v7.x` branch will have its first release
- prefer the `v4` tag to `v4.x` branch as reference in our workflow,
- Before `v4.x` branch, the branch will be converted into a tag when the support is dropped
- So `v3.x` branch will be converted as tag when `v5.x` branch will have its first release
- 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
You can report a Vulnerability by [my email](mailto:romain.lespinasse@gmail.com).
In this project, you can report a Vulnerability by creating a [draft security advisory](https://github.com/rlespinasse/github-slug-action/security/advisories).
_Vulnerability stages :_
- Reported,
- Confirmed (or declined),
- Fixed on maintained version series.
After a vulnerability fix, an GitHub issue will be created as document this vulnerability.
If the vulnerability is confirmed, a fix will be produced and the advisory will be published.

View File

@@ -13,84 +13,108 @@ inputs:
description: "Max length of the slugified values"
default: "63"
required: true
short-length:
description: "Length of the shortify values (git default if empty)"
required: false
runs:
using: "composite"
steps:
- run: $GITHUB_ACTION_PATH/preflight.sh
id: prefligth
shell: bash
env:
INPUT_SLUG_MAXLENGTH: ${{ inputs.slug-maxlength }}
INPUT_SHORT_LENGTH: ${{ inputs.short-length }}
- uses: rlespinasse/slugify-value@v1.2.0
# From Environment Variables
- uses: rlespinasse/slugify-value@v1.4.0
with:
key: GITHUB_REPOSITORY
value: ${{ github.repository }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/slugify-value@v1.2.0
- uses: rlespinasse/slugify-value@v1.4.0
with:
key: GITHUB_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/slugify-value@v1.2.0
- uses: rlespinasse/slugify-value@v1.4.0
with:
key: GITHUB_HEAD_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/slugify-value@v1.2.0
- uses: rlespinasse/slugify-value@v1.4.0
with:
key: GITHUB_BASE_REF
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
# Specific values
- uses: rlespinasse/slugify-value@v1.2.0
# From Specific values
- uses: rlespinasse/slugify-value@v1.4.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.2.0
- uses: rlespinasse/slugify-value@v1.4.0
with:
key: GITHUB_REF_NAME
value: ${{ steps.get-github-ref-name.outputs.github-ref-name }}
value: ${{ github.ref_name }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
- uses: rlespinasse/slugify-value@v1.4.0
with:
key: GITHUB_REF_POINT
value: ${{ env.GITHUB_HEAD_REF_RAW || env.GITHUB_REF_NAME_RAW }}
prefix: ${{ inputs.prefix }}
slug-maxlength: ${{ inputs.slug-maxlength }}
env:
GITHUB_HEAD_REF_RAW: ${{ github.head_ref }}
GITHUB_REF_NAME_RAW: ${{ github.ref_name }}
# From Calculated values
- id: get-github-repository-owner-part
run: echo "::set-output name=github-repository-owner-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f1)"
run: |
ownerpart=$(echo $GITHUB_REPOSITORY | cut -d/ -f1)
if [ -f "$GITHUB_OUTPUT" ]; then
echo "github-repository-owner-part=${ownerpart}" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=github-repository-owner-part::${ownerpart}"
fi
shell: bash
- uses: rlespinasse/slugify-value@v1.2.0
- uses: rlespinasse/slugify-value@v1.4.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)"
run: |
namepart=$(echo $GITHUB_REPOSITORY | cut -d/ -f2)
if [ -f "$GITHUB_OUTPUT" ]; then
echo "github-repository-name-part=${namepart}" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=github-repository-name-part::${namepart}"
fi
shell: bash
- uses: rlespinasse/slugify-value@v1.2.0
- uses: rlespinasse/slugify-value@v1.4.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
# From sha
- uses: rlespinasse/shortify-git-revision@v1.6.0
with:
name: GITHUB_SHA
short-on-error: true
length: 8
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
prefix: ${{ inputs.prefix }}
- uses: rlespinasse/shortify-git-revision@v1.4.0
- uses: rlespinasse/shortify-git-revision@v1.6.0
with:
name: GITHUB_EVENT_PULL_REQUEST_HEAD_SHA
revision: ${{ github.event.pull_request.head.sha }}
short-on-error: true
length: 8
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
prefix: ${{ inputs.prefix }}

View File

@@ -12,10 +12,10 @@ All `GitHub` variables availables in your workflow in addition of ones exposed b
- [Action-managed Event Variables](#action-managed-event-variables)
- [create](#create)
- [delete](#delete)
- [pull_request](#pull_request)
- [pull_request_review](#pull_request_review)
- [pull_request_review_comment](#pull_request_review_comment)
- [pull_request_target](#pull_request_target)
- [pull\_request](#pull_request)
- [pull\_request\_review](#pull_request_review)
- [pull\_request\_review\_comment](#pull_request_review_comment)
- [pull\_request\_target](#pull_request_target)
## Default environment variables
@@ -23,13 +23,14 @@ Read the official documentation about [Default environment variables][1].
### Action-managed Environment Variables
| Action-managed Variables | Can be suffix by |
| ------------------------ | -------------------- |
| GITHUB_REPOSITORY | `_SLUG`, `_SLUG_URL` |
| GITHUB_REF | `_SLUG`, `_SLUG_URL` |
| GITHUB_HEAD_REF | `_SLUG`, `_SLUG_URL` |
| GITHUB_BASE_REF | `_SLUG`, `_SLUG_URL` |
| GITHUB_SHA | `_SHORT` |
| Action-managed Variables | Can be suffix by |
| ------------------------ | --------------- |
| GITHUB_REPOSITORY | `_SLUG`, `_SLUG_URL` |
| GITHUB_REF | `_SLUG`, `_SLUG_URL` |
| GITHUB_REF_NAME | `_SLUG`, `_SLUG_URL` |
| GITHUB_HEAD_REF | `_SLUG`, `_SLUG_URL` |
| GITHUB_BASE_REF | `_SLUG`, `_SLUG_URL` |
| GITHUB_SHA | `_SHORT` |
## Variables from events
@@ -41,50 +42,50 @@ Read the official documentation about [Events that trigger workflows][2].
Checkout [create][3] webhook payload content
| Action-managed Variables | Available as |
| ------------------------ | ------------------------- |
| github.event.ref | GITHUB_EVENT_REF_SLUG |
| github.event.ref | GITHUB_EVENT_REF_SLUG_URL |
| Action-managed Variables | Available as |
| ------------------------ | ------------ |
| github.event.ref | GITHUB_EVENT_REF_SLUG |
| github.event.ref | GITHUB_EVENT_REF_SLUG_URL |
#### delete
Checkout [delete][4] webhook payload content
| Action-managed Variables | Available as |
| ------------------------ | ------------------------- |
| github.event.ref | GITHUB_EVENT_REF_SLUG |
| github.event.ref | GITHUB_EVENT_REF_SLUG_URL |
| Action-managed Variables | Available as |
| ------------------------ | ------------ |
| github.event.ref | GITHUB_EVENT_REF_SLUG |
| github.event.ref | GITHUB_EVENT_REF_SLUG_URL |
#### pull_request
Checkout [pull_request][5] webhook payload content
| Action-managed Variables | Available as |
| ---------------------------------- | ---------------------------------------- |
| Action-managed Variables | Available as |
| ------------------------ | ------------ |
| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT |
#### pull_request_review
Checkout [pull_request_review][6] webhook payload content
| Action-managed Variables | Available as |
| ---------------------------------- | ---------------------------------------- |
| Action-managed Variables | Available as |
| ------------------------ | ------------ |
| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT |
#### pull_request_review_comment
Checkout [pull_request_review_comment][7] webhook payload content
| Action-managed Variables | Available as |
| ---------------------------------- | ---------------------------------------- |
| Action-managed Variables | Available as |
| ------------------------ | ------------ |
| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT |
#### pull_request_target
Checkout [pull_request][5] webhook payload content
| Action-managed Variables | Available as |
| ---------------------------------- | ---------------------------------------- |
| Action-managed Variables | Available as |
| ------------------------ | ------------ |
| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT |
[1]: https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables

View File

@@ -4,25 +4,25 @@
- [Partial Variables](#partial-variables)
- [Table of Contents](#table-of-contents)
- [GITHUB_REPOSITORY_OWNER_PART](#github_repository_owner_part)
- [GITHUB_REPOSITORY_NAME_PART](#github_repository_name_part)
- [GITHUB\_REPOSITORY\_OWNER\_PART](#github_repository_owner_part)
- [GITHUB\_REPOSITORY\_NAME\_PART](#github_repository_name_part)
## GITHUB_REPOSITORY_OWNER_PART
Owner part of the environment variable **GITHUB_REPOSITORY**
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_OWNER_PART |
| ---------------------------- | ---------------------------- |
| octocat/Hello-World | octocat |
| rlespinasse/Hello-World.go | rlespinasse |
| AnotherPerson/SomeRepository | AnotherPerson |
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_OWNER_PART |
| ----------------- | ---------------------------- |
| octocat/Hello-World | octocat |
| rlespinasse/Hello-World.go | rlespinasse |
| AnotherPerson/SomeRepository | AnotherPerson |
## GITHUB_REPOSITORY_NAME_PART
Repository name part of the environment variable **GITHUB_REPOSITORY**
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_NAME_PART |
| ---------------------------- | --------------------------- |
| octocat/Hello-World | Hello-World |
| rlespinasse/Hello-World.go | Hello-World.go |
| AnotherPerson/SomeRepository | SomeRepository |
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_NAME_PART |
| ----------------- | --------------------------- |
| octocat/Hello-World | Hello-World |
| rlespinasse/Hello-World.go | Hello-World.go |
| AnotherPerson/SomeRepository | SomeRepository |

View File

@@ -4,8 +4,8 @@
- [Short Variables](#short-variables)
- [Table of Contents](#table-of-contents)
- [GITHUB_SHA_SHORT](#github_sha_short)
- [GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT](#github_event_pull_request_head_sha_short)
- [GITHUB\_SHA\_SHORT](#github_sha_short)
- [GITHUB\_EVENT\_PULL\_REQUEST\_HEAD\_SHA\_SHORT](#github_event_pull_request_head_sha_short)
## GITHUB_SHA_SHORT
@@ -13,15 +13,15 @@ Short the environment variable **GITHUB_SHA**
The commit SHA that triggered the workflow
| GITHUB_SHA | GITHUB_SHA_SHORT |
| ---------------------------------------- | ---------------- |
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
| GITHUB_SHA | GITHUB_SHA_SHORT |
| ---------- | ---------------- |
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
## GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT
Short the value of `github.event.pull_request.head.sha` that represents the last commit
used for triggering an action for a pull request.
| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT |
| ---------------------------------------- | ---------------------------------------- |
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT |
| ---------------------------------- | ---------------------------------------- |
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |

View File

@@ -4,13 +4,14 @@
- [Slug URL Variables](#slug-url-variables)
- [Table of Contents](#table-of-contents)
- [GITHUB_REPOSITORY_SLUG_URL](#github_repository_slug_url)
- [GITHUB_REPOSITORY_OWNER_PART_SLUG_URL](#github_repository_owner_part_slug_url)
- [GITHUB_REPOSITORY_NAME_PART_SLUG_URL](#github_repository_name_part_slug_url)
- [GITHUB_REF_SLUG_URL](#github_ref_slug_url)
- [GITHUB_HEAD_REF_SLUG_URL](#github_head_ref_slug_url)
- [GITHUB_BASE_REF_SLUG_URL](#github_base_ref_slug_url)
- [GITHUB_EVENT_REF_SLUG_URL](#github_event_ref_slug_url)
- [GITHUB\_REPOSITORY\_SLUG\_URL](#github_repository_slug_url)
- [GITHUB\_REPOSITORY\_OWNER\_PART\_SLUG\_URL](#github_repository_owner_part_slug_url)
- [GITHUB\_REPOSITORY\_NAME\_PART\_SLUG\_URL](#github_repository_name_part_slug_url)
- [GITHUB\_REF\_SLUG\_URL](#github_ref_slug_url)
- [GITHUB\_REF\_NAME\_SLUG\_URL](#github_ref_name_slug_url)
- [GITHUB\_HEAD\_REF\_SLUG\_URL](#github_head_ref_slug_url)
- [GITHUB\_BASE\_REF\_SLUG\_URL](#github_base_ref_slug_url)
- [GITHUB\_EVENT\_REF\_SLUG\_URL](#github_event_ref_slug_url)
## GITHUB_REPOSITORY_SLUG_URL
@@ -18,10 +19,10 @@ Slug URL the environment variable **GITHUB_REPOSITORY**
The owner and repository name.
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG_URL |
| ---------------------------- | ---------------------------- |
| octocat/Hello-World | octocat-hello-world |
| rlespinasse/Hello-World.go | rlespinasse-hello-world-go |
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG_URL |
| ----------------- | ---------------------------- |
| octocat/Hello-World | octocat-hello-world |
| rlespinasse/Hello-World.go | rlespinasse-hello-world-go |
| AnotherPerson/SomeRepository | anotherperson-somerepository |
## GITHUB_REPOSITORY_OWNER_PART_SLUG_URL
@@ -32,9 +33,9 @@ The Owner part of **GITHUB_REPOSITORY** variable.
| GITHUB_REPOSITORY_OWNER_PART | GITHUB_REPOSITORY_OWNER_PART_SLUG_URL |
| ---------------------------- | ------------------------------------- |
| octocat | octocat |
| rlespinasse | rlespinasse |
| AnotherPerson | anotherperson |
| octocat | octocat |
| rlespinasse | rlespinasse |
| AnotherPerson | anotherperson |
## GITHUB_REPOSITORY_NAME_PART_SLUG_URL
@@ -44,9 +45,9 @@ The Repository name part of **GITHUB_REPOSITORY** variable.
| GITHUB_REPOSITORY_NAME_PART | GITHUB_REPOSITORY_NAME_PART_SLUG_URL |
| --------------------------- | ------------------------------------ |
| Hello-World | hello-world |
| Hello-World.go | hello-world-go |
| SomeRepository | somerepository |
| Hello-World | hello-world |
| Hello-World.go | hello-world-go |
| SomeRepository | somerepository |
## GITHUB_REF_SLUG_URL
@@ -55,17 +56,30 @@ Slug URL the environment variable **GITHUB_REF**
The branch or tag ref that triggered the workflow.
_If neither a branch or tag is available for the event type, the variable will not exist._
| GITHUB_REF | GITHUB_REF_SLUG_URL |
| ------------------------------ | ------------------- |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/tags/v1.0.0 | v1-0-0 |
| refs/pull/42-merge | 42-merge |
| refs/tags/product@1.0.0-rc.2 | product-1-0-0-rc-2 |
| GITHUB_REF | GITHUB_REF_SLUG_URL |
| ---------- | ------------------- |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/tags/v1.0.0 | v1-0-0 |
| refs/pull/42/merge | 42-merge |
| refs/tags/product@1.0.0-rc.2 | product-1-0-0-rc-2 |
| refs/heads/New_Awesome_Product | new-awesome-product |
**Caution**: From v3.0.0 to v3.2.0 included, `GITHUB_REF_SLUG` have the wrong value on `pull_request` event.
`refs/pull/42-merge` become `refs-pull-42-merge` instead of `42-merge`. The bug have been fixed in v3.3.0
## GITHUB_REF_NAME_SLUG_URL
Slug URL the environment variable **GITHUB_REF_NAME**
The branch or tag ref that triggered the workflow.
_If neither a branch or tag is available for the event type, the variable will not exist._
| GITHUB_REF_NAME | GITHUB_REF_SLUG_URL |
| --------------- | ------------------- |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/tags/v1.0.0 | v1-0-0 |
| refs/pull/42/merge | 42-merge |
| refs/tags/product@1.0.0-rc.2 | product-1-0-0-rc-2 |
| refs/heads/New_Awesome_Product | new-awesome-product |
## GITHUB_HEAD_REF_SLUG_URL
@@ -74,11 +88,11 @@ Slug URL the environment variable **GITHUB_HEAD_REF**
The branch of the head repository.
_Only set for forked repositories._
| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL |
| ------------------------------ | ------------------------ |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL |
| ---------- | ------------------------ |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
## GITHUB_BASE_REF_SLUG_URL
@@ -87,23 +101,23 @@ Slug URL the environment variable **GITHUB_BASE_REF**
The branch of the base repository.
_Only set for forked repositories._
| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL |
| ------------------------------ | ------------------------ |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL |
| ---------- | ------------------------ |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
## GITHUB_EVENT_REF_SLUG_URL
Slug URL the variable **github.event.ref**
The git reference resource associated to triggered webhook.
The Git reference resource associated to triggered webhook.
_Only set for [`create`, and `delete`][1] events._
| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL |
| ------------------------------ | ------------------------ |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL |
| ---------- | ------------------------ |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
[1]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads

View File

@@ -4,13 +4,14 @@
- [Slug Variables](#slug-variables)
- [Table of Contents](#table-of-contents)
- [GITHUB_REPOSITORY_SLUG](#github_repository_slug)
- [GITHUB_REPOSITORY_OWNER_PART_SLUG](#github_repository_owner_part_slug)
- [GITHUB_REPOSITORY_NAME_PART_SLUG](#github_repository_name_part_slug)
- [GITHUB_REF_SLUG](#github_ref_slug)
- [GITHUB_HEAD_REF_SLUG](#github_head_ref_slug)
- [GITHUB_BASE_REF_SLUG](#github_base_ref_slug)
- [GITHUB_EVENT_REF_SLUG](#github_event_ref_slug)
- [GITHUB\_REPOSITORY\_SLUG](#github_repository_slug)
- [GITHUB\_REPOSITORY\_OWNER\_PART\_SLUG](#github_repository_owner_part_slug)
- [GITHUB\_REPOSITORY\_NAME\_PART\_SLUG](#github_repository_name_part_slug)
- [GITHUB\_REF\_SLUG](#github_ref_slug)
- [GITHUB\_REF\_NAME\_SLUG](#github_ref_name_slug)
- [GITHUB\_HEAD\_REF\_SLUG](#github_head_ref_slug)
- [GITHUB\_BASE\_REF\_SLUG](#github_base_ref_slug)
- [GITHUB\_EVENT\_REF\_SLUG](#github_event_ref_slug)
## GITHUB_REPOSITORY_SLUG
@@ -18,10 +19,10 @@ Slug the environment variable **GITHUB_REPOSITORY**
The owner and repository name.
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG |
| ---------------------------- | ---------------------------- |
| octocat/Hello-World | octocat-hello-world |
| rlespinasse/Hello-World.go | rlespinasse-hello-world.go |
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG |
| ----------------- | ---------------------- |
| octocat/Hello-World | octocat-hello-world |
| rlespinasse/Hello-World.go | rlespinasse-hello-world.go |
| AnotherPerson/SomeRepository | anotherperson-somerepository |
## GITHUB_REPOSITORY_OWNER_PART_SLUG
@@ -32,9 +33,9 @@ The Owner part of **GITHUB_REPOSITORY** variable.
| GITHUB_REPOSITORY_OWNER_PART | GITHUB_REPOSITORY_OWNER_PART_SLUG |
| ---------------------------- | --------------------------------- |
| octocat | octocat |
| rlespinasse | rlespinasse |
| AnotherPerson | anotherperson |
| octocat | octocat |
| rlespinasse | rlespinasse |
| AnotherPerson | anotherperson |
## GITHUB_REPOSITORY_NAME_PART_SLUG
@@ -44,9 +45,9 @@ The Repository name part of **GITHUB_REPOSITORY** variable.
| GITHUB_REPOSITORY_NAME_PART | GITHUB_REPOSITORY_NAME_PART_SLUG |
| --------------------------- | -------------------------------- |
| Hello-World | hello-world |
| Hello-World.go | hello-world.go |
| SomeRepository | somerepository |
| Hello-World | hello-world |
| Hello-World.go | hello-world.go |
| SomeRepository | somerepository |
## GITHUB_REF_SLUG
@@ -55,14 +56,30 @@ Slug the environment variable **GITHUB_REF**
The branch or tag ref that triggered the workflow.
_If neither a branch or tag is available for the event type, the variable will not exist._
| GITHUB_REF | GITHUB_REF_SLUG |
| ------------------------------ | ------------------- |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/tags/v1.0.0 | v1.0.0 |
| refs/tags/product@1.0.0-rc.2 | product-1.0.0-rc.2 |
| GITHUB_REF | GITHUB_REF_SLUG |
| ---------- | --------------- |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/tags/v1.0.0 | v1.0.0 |
| refs/tags/product@1.0.0-rc.2 | product-1.0.0-rc.2 |
| refs/heads/New_Awesome_Product | new-awesome-product |
## GITHUB_REF_NAME_SLUG
Slug the environment variable **GITHUB_REF_NAME**
The branch or tag ref that triggered the workflow.
_If neither a branch or tag is available for the event type, the variable will not exist._
| GITHUB_REF_NAME | GITHUB_REF_SLUG |
| --------------- | --------------- |
| main | main |
| feat/new_feature | feat-new-feature |
| v1.0.0 | v1.0.0 |
| product@1.0.0-rc.2 | product-1.0.0-rc.2 |
| New_Awesome_Product | new-awesome-product |
| 42/merge | 42-merge |
## GITHUB_HEAD_REF_SLUG
Slug the environment variable **GITHUB_HEAD_REF**
@@ -70,11 +87,11 @@ Slug the environment variable **GITHUB_HEAD_REF**
The branch of the head repository.
_Only set for [`pull-request`][1] event and forked repositories._
| GITHUB_REF | GITHUB_HEAD_REF_SLUG |
| ------------------------------ | -------------------- |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
| GITHUB_REF | GITHUB_HEAD_REF_SLUG |
| ---------- | -------------------- |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
## GITHUB_BASE_REF_SLUG
@@ -83,23 +100,23 @@ Slug the environment variable **GITHUB_BASE_REF**
The branch of the base repository.
_Only set for [`pull-request`][1] event and forked repositories._
| GITHUB_REF | GITHUB_HEAD_REF_SLUG |
| ------------------------------ | -------------------- |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
| GITHUB_REF | GITHUB_HEAD_REF_SLUG |
| ---------- | -------------------- |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
## GITHUB_EVENT_REF_SLUG
Slug the variable **github.event.ref**
The git reference resource associated to triggered webhook.
The Git reference resource associated to triggered webhook.
_Only set for [`create`, and `delete`][1] events._
| GITHUB_REF | GITHUB_HEAD_REF_SLUG |
| ------------------------------ | -------------------- |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
| GITHUB_REF | GITHUB_HEAD_REF_SLUG |
| ---------- | -------------------- |
| refs/heads/main | main |
| refs/heads/feat/new_feature | feat-new-feature |
| refs/heads/New_Awesome_Product | new-awesome-product |
[1]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads

View File

@@ -6,8 +6,8 @@ jobs:
usage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: rlespinasse/github-slug-action@v4
- uses: actions/checkout@v4
- uses: rlespinasse/github-slug-action@v5
- name: Output
run: |
echo "Partial variables"

View File

@@ -6,8 +6,8 @@ jobs:
usage:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: rlespinasse/github-slug-action@v4
- uses: actions/checkout@v4
- uses: rlespinasse/github-slug-action@v5
- name: Output
run: |
echo "Partial variables"

View File

@@ -6,15 +6,15 @@ jobs:
as_subdomain:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: rlespinasse/github-slug-action@v4
- uses: actions/checkout@v4
- uses: rlespinasse/github-slug-action@v5
- run: |
./deploy-application.sh --url "https://${{ env.GITHUB_REF_SLUG_URL }}.staging.app.example.com"
as_resource_path:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: rlespinasse/github-slug-action@v4
- uses: actions/checkout@v4
- uses: rlespinasse/github-slug-action@v5
- run: |
./deploy-application.sh --url "https://staging.app.example.com/${{ env.GITHUB_REF_SLUG_URL }}"

View File

@@ -6,8 +6,8 @@ jobs:
usage:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: rlespinasse/github-slug-action@v4
- uses: actions/checkout@v4
- uses: rlespinasse/github-slug-action@v5
- name: Output
run: |
echo "Partial variables"

View File

@@ -7,3 +7,32 @@ elif [ "${INPUT_SLUG_MAXLENGTH}" != "nolimit" ] && [ ! "${INPUT_SLUG_MAXLENGTH}"
echo "::error ::slug-maxlength must be a number or equals to 'nolimit'"
exit 1
fi
if [ ! "${INPUT_SHORT_LENGTH}" -eq "${INPUT_SHORT_LENGTH}" ] 2>/dev/null; then
echo "::error ::short-length must be a number"
exit 1
fi
echo "::debug ::Control preflight short-length setup"
PREFLIGHT_SHORT_LENGTH=""
if [ -n "${INPUT_SHORT_LENGTH}" ]; then
PREFLIGHT_SHORT_LENGTH="${INPUT_SHORT_LENGTH}"
echo "::debug ::Use input value: $PREFLIGHT_SHORT_LENGTH"
elif [ "$(git rev-parse --is-inside-work-tree)" == "true" ]; then
echo "::debug ::The action run inside a git repository, short-length can be empty"
else
echo "::debug ::The action run outside a git repository, need to set short-length"
PREFLIGHT_SHORT_LENGTH="$(git config --get core.abbrev)"
if [ -n "${PREFLIGHT_SHORT_LENGTH}" ]; then
echo "::debug ::Git Configuration 'core.abbrev' is set, using it as short-length"
else
PREFLIGHT_SHORT_LENGTH="7"
echo "::debug ::Using fallback value for short-length"
fi
fi
echo "::debug ::Set PREFLIGHT_SHORT_LENGTH=$PREFLIGHT_SHORT_LENGTH"
if [ -f "$GITHUB_OUTPUT" ]; then
echo "PREFLIGHT_SHORT_LENGTH=${PREFLIGHT_SHORT_LENGTH}" >> "$GITHUB_OUTPUT"
else
echo "::set-output name=PREFLIGHT_SHORT_LENGTH::${PREFLIGHT_SHORT_LENGTH}"
fi