mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-06-10 16:43:09 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e6f2616609 | ||
|
|
ef035f61a9 | ||
|
|
9e7def6155 | ||
|
|
e8d233181c | ||
|
|
6f7a8d2348 | ||
|
|
ac4a3a2668 | ||
|
|
6772bda8f6 | ||
|
|
846af0aca2 | ||
|
|
c33ff65466 | ||
|
|
50025f78ad | ||
|
|
8e1194b8b1 | ||
|
|
fe13438220 | ||
|
|
810e74b089 | ||
|
|
26e0654625 | ||
|
|
955b5ba456 | ||
|
|
ba00826602 | ||
|
|
797666298f | ||
|
|
56d132125c | ||
|
|
aba9f8db6e | ||
|
|
63a442f83b | ||
|
|
c6c92fed42 | ||
|
|
7c4f489627 | ||
|
|
45c9d47db8 |
2
.codespellrc
Normal file
2
.codespellrc
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
[codespell]
|
||||||
|
ignore-words-list = ans
|
||||||
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* @rlespinasse
|
||||||
24
.github/dependabot.yml
vendored
24
.github/dependabot.yml
vendored
@@ -1,27 +1,23 @@
|
|||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: "github-actions"
|
- package-ecosystem: 'github-actions'
|
||||||
directory: "/.github/"
|
directory: '/.github/'
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: 'weekly'
|
||||||
groups:
|
groups:
|
||||||
dependencies:
|
dependencies:
|
||||||
patterns:
|
patterns:
|
||||||
- "*"
|
- '*'
|
||||||
reviewers:
|
|
||||||
- "rlespinasse"
|
|
||||||
labels: []
|
labels: []
|
||||||
- package-ecosystem: "github-actions"
|
- package-ecosystem: 'github-actions'
|
||||||
directory: "/"
|
directory: '/'
|
||||||
commit-message:
|
commit-message:
|
||||||
prefix: "feat: "
|
prefix: 'feat: '
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: 'weekly'
|
||||||
groups:
|
groups:
|
||||||
dependencies:
|
dependencies:
|
||||||
patterns:
|
patterns:
|
||||||
- "rlespinasse/slugify-value"
|
- 'rlespinasse/slugify-value'
|
||||||
- "rlespinasse/shortify-git-revision"
|
- 'rlespinasse/shortify-git-revision'
|
||||||
reviewers:
|
|
||||||
- "rlespinasse"
|
|
||||||
labels: []
|
labels: []
|
||||||
|
|||||||
139
.github/workflows/check-variables.yml
vendored
Normal file
139
.github/workflows/check-variables.yml
vendored
Normal 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@v6
|
||||||
|
|
||||||
|
- 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@v9
|
||||||
|
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
|
||||||
15
.github/workflows/linter.yml
vendored
15
.github/workflows/linter.yml
vendored
@@ -3,6 +3,8 @@ name: Lint Code Base
|
|||||||
|
|
||||||
on: pull_request
|
on: pull_request
|
||||||
|
|
||||||
|
permissions: read-all
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Lint Code Base
|
name: Lint Code Base
|
||||||
@@ -13,15 +15,18 @@ jobs:
|
|||||||
statuses: write
|
statuses: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
# Full git history is needed to get a proper list of changed files within `super-linter`
|
# Full git history is needed to get a proper
|
||||||
|
# list of changed files within `super-linter`
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Lint Code Base
|
- name: Lint Code Base
|
||||||
uses: github/super-linter@v6
|
uses: super-linter/super-linter@v8
|
||||||
env:
|
env:
|
||||||
VALIDATE_ALL_CODEBASE: false
|
VALIDATE_ALL_CODEBASE: false
|
||||||
DEFAULT_BRANCH: v4.x
|
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
|
||||||
|
VALIDATE_JSCPD: false
|
||||||
|
VALIDATE_MARKDOWN_PRETTIER: false
|
||||||
|
VALIDATE_YAML_PRETTIER: false
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
name: '[v4] Test and Release'
|
name: "[v5] Test and Release"
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
permissions: read-all
|
||||||
jobs:
|
jobs:
|
||||||
check-v3compatibility:
|
check-v4-compatibility:
|
||||||
name: 'Check v3 compatibility'
|
name: "Check v4 compatibility"
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -10,16 +11,15 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Load using v4.x with prefix
|
- name: Load this action from HEAD
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|
||||||
|
- name: Load using v4
|
||||||
|
uses: rlespinasse/github-slug-action@v4
|
||||||
with:
|
with:
|
||||||
prefix: V4_
|
prefix: V4_
|
||||||
short-length: 8
|
|
||||||
|
|
||||||
- name: Load using v3.x
|
|
||||||
uses: rlespinasse/github-slug-action@v3.x
|
|
||||||
|
|
||||||
- name: Validate // Partial variables
|
- name: Validate // Partial variables
|
||||||
run: |
|
run: |
|
||||||
@@ -68,13 +68,13 @@ jobs:
|
|||||||
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL_CS }}" ]]
|
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL_CS }}" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Validate // Ref Name
|
- name: Validate // Ref Point
|
||||||
run: |
|
run: |
|
||||||
[[ "${{ env.GITHUB_REF_NAME }}" == "${{ env.V4_GITHUB_REF_NAME }}" ]]
|
[[ "${{ env.GITHUB_REF_POINT }}" == "${{ env.V4_GITHUB_REF_NAME }}" ]]
|
||||||
[[ "${{ env.GITHUB_REF_NAME_SLUG }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG }}" ]]
|
[[ "${{ env.GITHUB_REF_POINT_SLUG }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG }}" ]]
|
||||||
[[ "${{ env.GITHUB_REF_NAME_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL }}" ]]
|
[[ "${{ env.GITHUB_REF_POINT_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_POINT_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_CS }}" ]]
|
||||||
[[ "${{ env.GITHUB_REF_NAME_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL_CS }}" ]]
|
[[ "${{ env.GITHUB_REF_POINT_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL_CS }}" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Validate // Short SHA variables
|
- name: Validate // Short SHA variables
|
||||||
@@ -83,10 +83,10 @@ jobs:
|
|||||||
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
|
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
check-v3compatibility-without-checkout:
|
check-v4-compatibility-without-checkout:
|
||||||
name: 'Check v3 compatibility (without checkout)'
|
name: "Check v4 compatibility (without checkout)"
|
||||||
needs:
|
needs:
|
||||||
- check-v3compatibility
|
- check-v4-compatibility
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -94,19 +94,18 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
path: this-action
|
path: this-action
|
||||||
ref: ${{ github.ref }}
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
- name: Load using v4.x with prefix
|
- name: Load this action from HEAD
|
||||||
uses: ./this-action
|
uses: ./this-action
|
||||||
|
|
||||||
|
- name: Load using v4
|
||||||
|
uses: rlespinasse/github-slug-action@v4
|
||||||
with:
|
with:
|
||||||
prefix: V4_
|
prefix: V4_
|
||||||
short-length: 8
|
|
||||||
|
|
||||||
- name: Load using v3.x
|
|
||||||
uses: rlespinasse/github-slug-action@v3.x
|
|
||||||
|
|
||||||
- name: Validate // Short SHA variables
|
- name: Validate // Short SHA variables
|
||||||
run: |
|
run: |
|
||||||
@@ -115,7 +114,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
display:
|
display:
|
||||||
name: 'Display produced variables'
|
name: "Display produced variables"
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
@@ -123,9 +122,9 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Load using v4.x
|
- name: Load this action from HEAD
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|
||||||
- name: Partial variables
|
- name: Partial variables
|
||||||
@@ -140,48 +139,55 @@ jobs:
|
|||||||
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}"
|
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}"
|
||||||
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}"
|
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}"
|
||||||
echo "ref : ${{ env.GITHUB_REF_SLUG }}"
|
echo "ref : ${{ env.GITHUB_REF_SLUG }}"
|
||||||
|
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG }}"
|
||||||
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
|
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
|
||||||
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
|
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
|
||||||
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
|
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Slug variables (Case Sensitive)
|
- name: Slug variables (Case Sensitive)
|
||||||
run: |
|
run: |
|
||||||
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_CS }}"
|
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_CS }}"
|
||||||
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}"
|
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}"
|
||||||
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}"
|
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}"
|
||||||
echo "ref : ${{ env.GITHUB_REF_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 "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_CS }}"
|
||||||
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_CS }}"
|
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_CS }}"
|
||||||
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_CS }}"
|
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_CS }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Slug URL variables
|
- name: Slug URL variables
|
||||||
run: |
|
run: |
|
||||||
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
||||||
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}"
|
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}"
|
||||||
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}"
|
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}"
|
||||||
echo "ref : ${{ env.GITHUB_REF_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 "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
|
||||||
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
|
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
|
||||||
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
|
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Slug URL variables (Case Sensitive)
|
- name: Slug URL variables (Case Sensitive)
|
||||||
run: |
|
run: |
|
||||||
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL_CS }}"
|
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL_CS }}"
|
||||||
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_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 "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}"
|
||||||
echo "ref : ${{ env.GITHUB_REF_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 "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL_CS }}"
|
||||||
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}"
|
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}"
|
||||||
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}"
|
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Ref Name
|
- name: Ref Point
|
||||||
run: |
|
run: |
|
||||||
echo "raw : ${{ env.GITHUB_REF_NAME }}"
|
echo "raw : ${{ env.GITHUB_REF_POINT }}"
|
||||||
echo "slug : ${{ env.GITHUB_REF_NAME_SLUG }}"
|
echo "slug : ${{ env.GITHUB_REF_POINT_SLUG }}"
|
||||||
echo "slug url : ${{ env.GITHUB_REF_NAME_SLUG_URL }}"
|
echo "slug url : ${{ env.GITHUB_REF_POINT_SLUG_URL }}"
|
||||||
echo "slug (Case Sensitive) : ${{ env.GITHUB_REF_NAME_SLUG_CS }}"
|
echo "slug (Case Sensitive) : ${{ env.GITHUB_REF_POINT_SLUG_CS }}"
|
||||||
echo "slug url (Case Sensitive) : ${{ env.GITHUB_REF_NAME_SLUG_URL_CS }}"
|
echo "slug url (Case Sensitive) : ${{ env.GITHUB_REF_POINT_SLUG_URL_CS }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Short SHA variables
|
- name: Short SHA variables
|
||||||
@@ -191,7 +197,7 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
display-without-checkout:
|
display-without-checkout:
|
||||||
name: 'Display produced variables (without checkout)'
|
name: "Display produced variables (without checkout)"
|
||||||
needs:
|
needs:
|
||||||
- display
|
- display
|
||||||
strategy:
|
strategy:
|
||||||
@@ -201,19 +207,13 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
path: this-action
|
path: this-action
|
||||||
ref: ${{ github.ref }}
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
- name: Load using v4.x with prefix
|
- name: Load this action from HEAD
|
||||||
uses: ./this-action
|
uses: ./this-action
|
||||||
with:
|
|
||||||
prefix: V4_
|
|
||||||
short-length: 8
|
|
||||||
|
|
||||||
- name: Load using v3.x
|
|
||||||
uses: rlespinasse/github-slug-action@v3.x
|
|
||||||
|
|
||||||
- name: Short SHA variables
|
- name: Short SHA variables
|
||||||
run: |
|
run: |
|
||||||
@@ -230,17 +230,17 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# Test 1
|
# Test 1
|
||||||
- name: Using correct short length
|
- name: Using correct short length
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
prefix: 'CSL_'
|
prefix: "CSL_"
|
||||||
short-length: 4
|
short-length: 4
|
||||||
- name: Using correct length // Validate that all short variables lengths are equals to short-length
|
- name: Using correct length // Validate that all short variables lengths are equals to short-length
|
||||||
run: |
|
run: |
|
||||||
env | grep "CSL_" | grep "_SHORT" | cut -d"=" -f2 | while read -r value; do [ "$(echo "$value" | wc -m)" -le 5 ] ; done
|
env | grep "CSL_" | grep "_SHORT" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 5 ] ; done
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
# Test 2
|
# Test 2
|
||||||
@@ -248,12 +248,12 @@ jobs:
|
|||||||
id: using-wrong-short-length
|
id: using-wrong-short-length
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
prefix: 'WSL_'
|
prefix: "WSL_"
|
||||||
short-length: 'wrong'
|
short-length: "wrong"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
- name: Using wrong short length // Validate that the action end with an error
|
- name: Using wrong short length // Validate that the action end with an error
|
||||||
run: |
|
run: |
|
||||||
[[ "$(env | grep "WSL_" | grep "_SHORT" | wc -l)" -eq 0 ]]
|
[[ "$(env | grep "WSL_" | grep "_SHORT" -c)" -eq 0 ]]
|
||||||
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
|
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
|
||||||
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
|
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -269,7 +269,7 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
with:
|
with:
|
||||||
path: this-action
|
path: this-action
|
||||||
ref: ${{ github.ref }}
|
ref: ${{ github.ref }}
|
||||||
@@ -278,11 +278,11 @@ jobs:
|
|||||||
- name: Using correct short length
|
- name: Using correct short length
|
||||||
uses: ./this-action
|
uses: ./this-action
|
||||||
with:
|
with:
|
||||||
prefix: 'CSL_'
|
prefix: "CSL_"
|
||||||
short-length: 4
|
short-length: 4
|
||||||
- name: Using correct length // Validate that all short variables lengths are equals to short-length
|
- name: Using correct length // Validate that all short variables lengths are equals to short-length
|
||||||
run: |
|
run: |
|
||||||
env | grep "CSL_" | grep "_SHORT" | cut -d"=" -f2 | while read -r value; do [ "$(echo "$value" | wc -m)" -le 5 ] ; done
|
env | grep "CSL_" | grep "_SHORT" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 5 ] ; done
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
# Test 2
|
# Test 2
|
||||||
@@ -290,11 +290,11 @@ jobs:
|
|||||||
id: using-empty-short-length
|
id: using-empty-short-length
|
||||||
uses: ./this-action
|
uses: ./this-action
|
||||||
with:
|
with:
|
||||||
prefix: 'ESL_'
|
prefix: "ESL_"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
- name: Using empty short length // Validate that the action don't end with an error
|
- name: Using empty short length // Validate that the action don't end with an error
|
||||||
run: |
|
run: |
|
||||||
[[ "$(env | grep "ESL_" | grep "_SHORT" | wc -l)" -gt 0 ]]
|
[[ "$(env | grep "ESL_" | grep "_SHORT" -c)" -gt 0 ]]
|
||||||
[[ "${{ steps.using-empty-short-length.outcome }}" == "success" ]]
|
[[ "${{ steps.using-empty-short-length.outcome }}" == "success" ]]
|
||||||
[[ "${{ steps.using-empty-short-length.conclusion }}" == "success" ]]
|
[[ "${{ steps.using-empty-short-length.conclusion }}" == "success" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -304,12 +304,12 @@ jobs:
|
|||||||
id: using-wrong-short-length
|
id: using-wrong-short-length
|
||||||
uses: ./this-action
|
uses: ./this-action
|
||||||
with:
|
with:
|
||||||
prefix: 'WSL_'
|
prefix: "WSL_"
|
||||||
short-length: 'wrong'
|
short-length: "wrong"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
- name: Using wrong short length // Validate that the action end with an error
|
- name: Using wrong short length // Validate that the action end with an error
|
||||||
run: |
|
run: |
|
||||||
[[ "$(env | grep "WSL_" | grep "_SHORT" | wc -l)" -eq 0 ]]
|
[[ "$(env | grep "WSL_" | grep "_SHORT" -c)" -eq 0 ]]
|
||||||
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
|
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
|
||||||
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
|
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -323,17 +323,17 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# Test 1
|
# Test 1
|
||||||
- name: Using correct slug max length
|
- name: Using correct slug max length
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
prefix: 'CML_'
|
prefix: "CML_"
|
||||||
slug-maxlength: 1
|
slug-maxlength: 1
|
||||||
- name: Using correct max length // Validate that all slug variables lengths are equals or under the slug-maxlength
|
- name: Using correct max length // Validate that all slug variables lengths are equals or under the slug-maxlength
|
||||||
run: |
|
run: |
|
||||||
env | grep "CML_" | grep "_SLUG" | cut -d"=" -f2 | while read -r value; do [ "$(echo "$value" | wc -m)" -le 2 ] ; done
|
env | grep "CML_" | grep "_SLUG" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 2 ] ; done
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
# Test 2
|
# Test 2
|
||||||
@@ -341,12 +341,12 @@ jobs:
|
|||||||
id: using-wrong-slug-max-length
|
id: using-wrong-slug-max-length
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
prefix: 'WML_'
|
prefix: "WML_"
|
||||||
slug-maxlength: 'wrong'
|
slug-maxlength: "wrong"
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
- name: Using wrong slug max length // Validate that the action end with an error
|
- name: Using wrong slug max length // Validate that the action end with an error
|
||||||
run: |
|
run: |
|
||||||
[[ "$(env | grep "WML_" | grep "_SLUG" | wc -l)" -eq 0 ]]
|
[[ "$(env | grep "WML_" | grep "_SLUG" -c)" -eq 0 ]]
|
||||||
[[ "${{ steps.using-wrong-slug-max-length.outcome }}" == "failure" ]]
|
[[ "${{ steps.using-wrong-slug-max-length.outcome }}" == "failure" ]]
|
||||||
[[ "${{ steps.using-wrong-slug-max-length.conclusion }}" == "success" ]]
|
[[ "${{ steps.using-wrong-slug-max-length.conclusion }}" == "success" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -356,12 +356,12 @@ jobs:
|
|||||||
id: using-empty-slug-max-length
|
id: using-empty-slug-max-length
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
prefix: 'EML_'
|
prefix: "EML_"
|
||||||
slug-maxlength: ''
|
slug-maxlength: ""
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
- name: Using empty slug max length // Validate that the action end with an error
|
- name: Using empty slug max length // Validate that the action end with an error
|
||||||
run: |
|
run: |
|
||||||
[[ "$(env | grep "EML_" | grep "_SLUG" | wc -l)" -eq 0 ]]
|
[[ "$(env | grep "EML_" | grep "_SLUG" -c)" -eq 0 ]]
|
||||||
[[ "${{ steps.using-empty-slug-max-length.outcome }}" == "failure" ]]
|
[[ "${{ steps.using-empty-slug-max-length.outcome }}" == "failure" ]]
|
||||||
[[ "${{ steps.using-empty-slug-max-length.conclusion }}" == "success" ]]
|
[[ "${{ steps.using-empty-slug-max-length.conclusion }}" == "success" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
@@ -371,27 +371,31 @@ jobs:
|
|||||||
id: using-nolimit-slug-max-length
|
id: using-nolimit-slug-max-length
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
prefix: 'NLML_'
|
prefix: "NLML_"
|
||||||
slug-maxlength: 'nolimit'
|
slug-maxlength: "nolimit"
|
||||||
- name: Using no limit on slug max length // Validate that the action end with an error
|
- name: Using no limit on slug max length // Validate that the action end with an error
|
||||||
run: |
|
run: |
|
||||||
[[ "$(env | grep "NLML_" | grep "_SLUG" | wc -l)" -gt 0 ]]
|
[[ "$(env | grep "NLML_" | grep "_SLUG" -c)" -gt 0 ]]
|
||||||
[[ "${{ steps.using-nolimit-slug-max-length.outcome }}" == "success" ]]
|
[[ "${{ steps.using-nolimit-slug-max-length.outcome }}" == "success" ]]
|
||||||
[[ "${{ steps.using-nolimit-slug-max-length.conclusion }}" == "success" ]]
|
[[ "${{ steps.using-nolimit-slug-max-length.conclusion }}" == "success" ]]
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
release:
|
release:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
issues: write
|
||||||
|
id-token: write
|
||||||
|
packages: write
|
||||||
concurrency:
|
concurrency:
|
||||||
group: release-${{ github.ref }}-${{ github.event_name }}
|
group: release-${{ github.ref }}-${{ github.event_name }}
|
||||||
needs:
|
needs:
|
||||||
- check-v3compatibility-without-checkout
|
|
||||||
- display-without-checkout
|
- display-without-checkout
|
||||||
- input-short-length-without-checkout
|
- input-short-length-without-checkout
|
||||||
- input-slug-maxlength
|
- input-slug-maxlength
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
- name: Release this GitHub Action
|
- name: Release this GitHub Action
|
||||||
uses: rlespinasse/release-that@v1
|
uses: rlespinasse/release-that@v1
|
||||||
with:
|
with:
|
||||||
@@ -1,76 +1,133 @@
|
|||||||
|
|
||||||
# Contributor Covenant Code of Conduct
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
## Our Pledge
|
## Our Pledge
|
||||||
|
|
||||||
In the interest of fostering an open and welcoming environment, we as
|
We as members, contributors, and leaders pledge to make participation in our
|
||||||
contributors and maintainers pledge to making participation in our project and
|
community a harassment-free experience for everyone, regardless of age, body
|
||||||
our community a harassment-free experience for everyone, regardless of age, body
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
identity and expression, level of experience, education, socio-economic status,
|
||||||
level of experience, education, socio-economic status, nationality, personal
|
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||||
appearance, race, religion, or sexual identity and orientation.
|
identity and orientation.
|
||||||
|
|
||||||
|
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||||
|
diverse, inclusive, and healthy community.
|
||||||
|
|
||||||
## Our Standards
|
## Our Standards
|
||||||
|
|
||||||
Examples of behavior that contributes to creating a positive environment
|
Examples of behavior that contributes to a positive environment for our
|
||||||
include:
|
community include:
|
||||||
|
|
||||||
* Using welcoming and inclusive language
|
* Demonstrating empathy and kindness toward other people
|
||||||
* Being respectful of differing viewpoints and experiences
|
* Being respectful of differing opinions, viewpoints, and experiences
|
||||||
* Gracefully accepting constructive criticism
|
* Giving and gracefully accepting constructive feedback
|
||||||
* Focusing on what is best for the community
|
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||||
* Showing empathy towards other community members
|
and learning from the experience
|
||||||
|
* Focusing on what is best not just for us as individuals, but for the overall
|
||||||
|
community
|
||||||
|
|
||||||
Examples of unacceptable behavior by participants include:
|
Examples of unacceptable behavior include:
|
||||||
|
|
||||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||||
advances
|
any kind
|
||||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||||
* Public or private harassment
|
* Public or private harassment
|
||||||
* Publishing others' private information, such as a physical or electronic
|
* Publishing others' private information, such as a physical or email address,
|
||||||
address, without explicit permission
|
without their explicit permission
|
||||||
* Other conduct which could reasonably be considered inappropriate in a
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
professional setting
|
professional setting
|
||||||
|
|
||||||
## Our Responsibilities
|
## Enforcement Responsibilities
|
||||||
|
|
||||||
Project maintainers are responsible for clarifying the standards of acceptable
|
Community leaders are responsible for clarifying and enforcing our standards of
|
||||||
behavior and are expected to take appropriate and fair corrective action in
|
acceptable behavior and will take appropriate and fair corrective action in
|
||||||
response to any instances of unacceptable behavior.
|
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||||
|
or harmful.
|
||||||
|
|
||||||
Project maintainers have the right and responsibility to remove, edit, or
|
Community leaders have the right and responsibility to remove, edit, or reject
|
||||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||||
permanently any contributor for other behaviors that they deem inappropriate,
|
decisions when appropriate.
|
||||||
threatening, offensive, or harmful.
|
|
||||||
|
|
||||||
## Scope
|
## Scope
|
||||||
|
|
||||||
This Code of Conduct applies both within project spaces and in public spaces
|
This Code of Conduct applies within all community spaces, and also applies when
|
||||||
when an individual is representing the project or its community. Examples of
|
an individual is officially representing the community in public spaces.
|
||||||
representing a project or community include using an official project e-mail
|
Examples of representing our community include using an official email address,
|
||||||
address, posting via an official social media account, or acting as an appointed
|
posting via an official social media account, or acting as an appointed
|
||||||
representative at an online or offline event. Representation of a project may be
|
representative at an online or offline event.
|
||||||
further defined and clarified by project maintainers.
|
|
||||||
|
|
||||||
## Enforcement
|
## Enforcement
|
||||||
|
|
||||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
reported by contacting the project team at romain.lespinasse@gmail.com. All
|
reported to the community leaders responsible for enforcement at
|
||||||
complaints will be reviewed and investigated and will result in a response that
|
<romain.lespinasse@gmail.com>.
|
||||||
is deemed necessary and appropriate to the circumstances. The project team is
|
All complaints will be reviewed and investigated promptly and fairly.
|
||||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
||||||
Further details of specific enforcement policies may be posted separately.
|
|
||||||
|
|
||||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
All community leaders are obligated to respect the privacy and security of the
|
||||||
faith may face temporary or permanent repercussions as determined by other
|
reporter of any incident.
|
||||||
members of the project's leadership.
|
|
||||||
|
## Enforcement Guidelines
|
||||||
|
|
||||||
|
Community leaders will follow these Community Impact Guidelines in determining
|
||||||
|
the consequences for any action they deem in violation of this Code of Conduct:
|
||||||
|
|
||||||
|
### 1. Correction
|
||||||
|
|
||||||
|
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||||
|
unprofessional or unwelcome in the community.
|
||||||
|
|
||||||
|
**Consequence**: A private, written warning from community leaders, providing
|
||||||
|
clarity around the nature of the violation and an explanation of why the
|
||||||
|
behavior was inappropriate. A public apology may be requested.
|
||||||
|
|
||||||
|
### 2. Warning
|
||||||
|
|
||||||
|
**Community Impact**: A violation through a single incident or series of
|
||||||
|
actions.
|
||||||
|
|
||||||
|
**Consequence**: A warning with consequences for continued behavior. No
|
||||||
|
interaction with the people involved, including unsolicited interaction with
|
||||||
|
those enforcing the Code of Conduct, for a specified period of time. This
|
||||||
|
includes avoiding interactions in community spaces as well as external channels
|
||||||
|
like social media. Violating these terms may lead to a temporary or permanent
|
||||||
|
ban.
|
||||||
|
|
||||||
|
### 3. Temporary Ban
|
||||||
|
|
||||||
|
**Community Impact**: A serious violation of community standards, including
|
||||||
|
sustained inappropriate behavior.
|
||||||
|
|
||||||
|
**Consequence**: A temporary ban from any sort of interaction or public
|
||||||
|
communication with the community for a specified period of time. No public or
|
||||||
|
private interaction with the people involved, including unsolicited interaction
|
||||||
|
with those enforcing the Code of Conduct, is allowed during this period.
|
||||||
|
Violating these terms may lead to a permanent ban.
|
||||||
|
|
||||||
|
### 4. Permanent Ban
|
||||||
|
|
||||||
|
**Community Impact**: Demonstrating a pattern of violation of community
|
||||||
|
standards, including sustained inappropriate behavior, harassment of an
|
||||||
|
individual, or aggression toward or disparagement of classes of individuals.
|
||||||
|
|
||||||
|
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||||
|
community.
|
||||||
|
|
||||||
## Attribution
|
## Attribution
|
||||||
|
|
||||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
version 2.1, available at
|
||||||
|
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
||||||
|
|
||||||
|
Community Impact Guidelines were inspired by
|
||||||
|
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see the FAQ at
|
||||||
|
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
||||||
|
[https://www.contributor-covenant.org/translations][translations].
|
||||||
|
|
||||||
[homepage]: https://www.contributor-covenant.org
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||||
For answers to common questions about this code of conduct, see
|
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||||
https://www.contributor-covenant.org/faq
|
[FAQ]: https://www.contributor-covenant.org/faq
|
||||||
|
[translations]: https://www.contributor-covenant.org/translations
|
||||||
|
|||||||
292
README.md
292
README.md
@@ -1,241 +1,93 @@
|
|||||||
# GitHub Slug action
|
# GitHub Slug Action
|
||||||
|
|
||||||
This GitHub Action will expose the slug/short values of [some GitHub environment variables][default-environment-variables] inside your GitHub workflow.
|
This GitHub Action exposes slug and short values of [GitHub environment variables][default-environment-variables] inside your workflow.
|
||||||
|
|
||||||
## Table of Contents
|
## Quick Start
|
||||||
|
|
||||||
- [GitHub Slug action](#github-slug-action)
|
|
||||||
- [Table of Contents](#table-of-contents)
|
|
||||||
- [Overview](#overview)
|
|
||||||
- [Use this action](#use-this-action)
|
|
||||||
- [Migration from previous versions](#migration-from-previous-versions)
|
|
||||||
- [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)
|
|
||||||
- [The SHORT variables doesn't have the same lengths as before](#the-short-variables-doesnt-have-the-same-lengths-as-before)
|
|
||||||
- [One of the environment variables doesn't work as intended](#one-of-the-environment-variables-doesnt-work-as-intended)
|
|
||||||
- [Known environment variable conflicts](#known-environment-variable-conflicts)
|
|
||||||
- [GITHUB_REF_NAME](#github_ref_name)
|
|
||||||
- [An action could not be found at the URI](#an-action-could-not-be-found-at-the-uri)
|
|
||||||
- [Thanks for talking about us](#thanks-for-talking-about-us)
|
|
||||||
|
|
||||||
## Overview
|
|
||||||
|
|
||||||
`SLUG` on a variable will
|
|
||||||
|
|
||||||
- put the variable content in lower case
|
|
||||||
- replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
|
||||||
- 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>
|
|
||||||
|
|
||||||
- `SLUG_URL` on a variable to have a `slug` variable compliant to be used in an URL
|
|
||||||
- Like `SLUG` but `.`, and `_` are also replaced by `-`
|
|
||||||
- `SHORT` on a variable will limit the string size to ~8 characters
|
|
||||||
- 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`
|
|
||||||
|
|
||||||
Additional enhanced environment variables can be compute to help you around GitHub environment variables.
|
|
||||||
</p>
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## Use this action
|
|
||||||
|
|
||||||
Add this in your workflow
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Inject slug/short variables
|
steps:
|
||||||
uses: rlespinasse/github-slug-action@v4
|
- uses: actions/checkout@v6
|
||||||
|
- name: Inject enhanced GitHub environment variables
|
||||||
|
uses: rlespinasse/github-slug-action@v5
|
||||||
```
|
```
|
||||||
|
|
||||||
<details>
|
> [!CAUTION]
|
||||||
<summary>Others configurations</summary>
|
> Use [Dependabot][dependabot] to maintain your `github-slug-action` version updated in your GitHub workflows.
|
||||||
<p>
|
|
||||||
|
|
||||||
- With a prefix
|
## What It Does
|
||||||
|
|
||||||
```yaml
|
- **SLUG** -- Lowercase, replace special characters with `-`, limit to 63 characters. _Dots and underscores preserved._
|
||||||
- name: Inject slug/short variables
|
- **SLUG_URL** -- Same as SLUG, but dots and underscores are also replaced. _Safe for URLs and subdomains._
|
||||||
uses: rlespinasse/github-slug-action@v4
|
- **SHORT** -- Shorten Git SHA values to a unique prefix.
|
||||||
with:
|
- **PART** -- Extract portions of a variable (e.g., owner or repository name from `GITHUB_REPOSITORY`).
|
||||||
prefix: CI_
|
- **_CS** -- Case-sensitive variants of SLUG and SLUG_URL (original casing preserved).
|
||||||
```
|
|
||||||
|
|
||||||
- With another max length for slug values
|
> [!TIP]
|
||||||
|
> Read the [slug transformation rules](docs/explanation/slug-transformation-rules.md) for the full algorithm and rationale.
|
||||||
|
|
||||||
```yaml
|
## Inputs
|
||||||
- name: Inject slug/short variables
|
|
||||||
uses: rlespinasse/github-slug-action@v4
|
|
||||||
with:
|
|
||||||
slug-maxlength: 80 # Use 'nolimit' to remove use of a max length (Default to 63)
|
|
||||||
```
|
|
||||||
|
|
||||||
- With another length for short values
|
| Input | Default | Description |
|
||||||
|
| ----- | ------- | ----------- |
|
||||||
|
| `prefix` | `""` | Value prepended to each generated variable name |
|
||||||
|
| `slug-maxlength` | `63` | Max length of slugified values (`"nolimit"` to disable) |
|
||||||
|
| `short-length` | _(Git default)_ | Length of short SHA values (minimum `4`) |
|
||||||
|
|
||||||
```yaml
|
See the [inputs reference](docs/reference/inputs.md) for details.
|
||||||
- name: Inject slug/short variables
|
|
||||||
uses: rlespinasse/github-slug-action@v4
|
|
||||||
with:
|
|
||||||
short-length: 7 # By default it's up to git to decide, use 8 to have the v3.x behavior
|
|
||||||
```
|
|
||||||
|
|
||||||
**Warning**: If you leave it empty, you need to checkout the source first in order to let git decide the size by itself.
|
## Available Variables
|
||||||
</p>
|
|
||||||
</details>
|
|
||||||
|
|
||||||
Check for more [examples][examples] (OS usage, URL use, ...)
|
| Variable | Type | Description |
|
||||||
|
| -------- | ---- | ----------- |
|
||||||
|
| [GITHUB_REF_POINT](docs/reference/variables.md#github_ref_point) | Enhanced | Branch or tag name (consistent across event types) |
|
||||||
|
| [GITHUB_REPOSITORY_OWNER_PART](docs/reference/variables.md#github_repository_owner_part) | Partial | Owner extracted from repository |
|
||||||
|
| [GITHUB_REPOSITORY_NAME_PART](docs/reference/variables.md#github_repository_name_part) | Partial | Repository name extracted from repository |
|
||||||
|
| [GITHUB_REPOSITORY_SLUG](docs/reference/variables.md#github_repository_slug) | Slug | The owner and repository name |
|
||||||
|
| [GITHUB_REF_SLUG](docs/reference/variables.md#github_ref_slug) | Slug | The branch or tag ref |
|
||||||
|
| [GITHUB_REF_NAME_SLUG](docs/reference/variables.md#github_ref_name_slug) | Slug | The branch or tag name shown on GitHub |
|
||||||
|
| [GITHUB_HEAD_REF_SLUG](docs/reference/variables.md#github_head_ref_slug) | Slug | PR head branch |
|
||||||
|
| [GITHUB_BASE_REF_SLUG](docs/reference/variables.md#github_base_ref_slug) | Slug | PR base branch |
|
||||||
|
| [GITHUB_EVENT_REF_SLUG](docs/reference/variables.md#github_event_ref_slug) | Slug | Webhook Git ref |
|
||||||
|
| [GITHUB_SHA_SHORT](docs/reference/variables.md#github_sha_short) | Short | Shortened commit SHA |
|
||||||
|
| [GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT](docs/reference/variables.md#github_event_pull_request_head_sha_short) | Short | Shortened PR head commit SHA |
|
||||||
|
|
||||||
**Tip:** Use [Dependabot][dependabot] to maintain your `github-slug-action` version updated in your GitHub workflows.
|
All slug variables also have `_SLUG_URL` and `_CS` variants. See the [full variable reference](docs/reference/variables.md).
|
||||||
|
|
||||||
### Migration from previous versions
|
> [!TIP]
|
||||||
|
> If you don't find what you need, read about [available GitHub variables](docs/reference/github-variables.md), [propose a new variable][custom-variable], or use [slugify-value][slugify-value] / [shortify-git-revision][shortify-git-revision] directly.
|
||||||
|
|
||||||
The short sha length is not the same as previous version.
|
## Documentation
|
||||||
|
|
||||||
- `v4` let git configuration decide of it (but you can override it),
|
### Tutorial
|
||||||
- `v3` and before, it's always a length of 8 characters.
|
|
||||||
|
|
||||||
So to reproduce previous behavior, use
|
- [Getting started](docs/getting-started.md) -- Step-by-step guide for first-time users
|
||||||
|
|
||||||
```yaml
|
### How-To Guides
|
||||||
- name: Inject slug/short variables
|
|
||||||
uses: rlespinasse/github-slug-action@v4
|
|
||||||
with:
|
|
||||||
short-length: 8 # Same as v3 and before
|
|
||||||
```
|
|
||||||
|
|
||||||
## Available Environment variables
|
- [Use a prefix](docs/how-to/use-prefix.md)
|
||||||
|
- [Configure slug max length](docs/how-to/configure-slug-maxlength.md)
|
||||||
|
- [Configure short SHA length](docs/how-to/configure-short-length.md)
|
||||||
|
- [Use slug variables in URLs](docs/how-to/use-slugs-in-urls.md)
|
||||||
|
- More [workflow examples](https://github.com/rlespinasse/github-slug-action/tree/v5.x/examples) (OS-specific usage, URL patterns)
|
||||||
|
|
||||||
**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].
|
### Reference
|
||||||
|
|
||||||
### Enhanced variables
|
- [Variable reference](docs/reference/variables.md) -- All variables with transformation examples
|
||||||
|
- [Inputs reference](docs/reference/inputs.md) -- Action inputs specification
|
||||||
|
- [GitHub variables by event](docs/reference/github-variables.md) -- Which variables are available per event type
|
||||||
|
|
||||||
- `GITHUB_REF_NAME` will contains the reference name (branch or tag)
|
### Explanation
|
||||||
- based on `GITHUB_HEAD_REF` in a [`pull-request*`][webhooks-and-events] event context,
|
|
||||||
- based on `GITHUB_REF` in others event context.
|
|
||||||
|
|
||||||
**NOTE:** All enhanced variables are available in all **slug** formats.
|
- [Slug transformation rules](docs/explanation/slug-transformation-rules.md) -- How and why transformations work
|
||||||
|
|
||||||
### Partial variables
|
## Migration
|
||||||
|
|
||||||
| Variable | Partial version of | Description |
|
- [Migrate from v4 to v5](docs/how-to/migrate-v4-to-v5.md) -- `GITHUB_REF_NAME` behaviour changed on pull request events
|
||||||
| -------------------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------ |
|
- [Migrate from v3 to v4](docs/how-to/migrate-v3-to-v4.md) -- Short SHA length is now determined by Git
|
||||||
| [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 |
|
|
||||||
|
|
||||||
### Slug variables
|
|
||||||
|
|
||||||
**NOTE:** `_CS` suffix available
|
|
||||||
|
|
||||||
| 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> |
|
|
||||||
|
|
||||||
### Slug URL variables
|
|
||||||
|
|
||||||
**NOTE:** `_CS` suffix available
|
|
||||||
|
|
||||||
| 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> |
|
|
||||||
|
|
||||||
### 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> |
|
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
### The SHORT variables doesn't have the same lengths as before
|
See the [troubleshooting guide](docs/how-to/troubleshooting.md) for common issues and solutions.
|
||||||
|
|
||||||
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 our repository and can differ over time.
|
|
||||||
|
|
||||||
To manage that moving length, you can use `short-length` input
|
|
||||||
|
|
||||||
- set `7` to reproduce `small repository` behavior
|
|
||||||
- set `8` to reproduce `v3` behavior
|
|
||||||
|
|
||||||
**Warning**: The minimum length is 4, the default is the effective value of the [core.abbrev][git-core-abbrev] configuration variable.
|
|
||||||
|
|
||||||
### One of the environment variables doesn't work as intended
|
|
||||||
|
|
||||||
[**Note**][naming-conventions]: When you set a custom environment variable, you cannot use any of the default environment variable names. For a complete list of these, see [Default environment variables][default-environment-variables]. **If you attempt to override the value of one of these default environment variables, the assignment is ignored.**
|
|
||||||
|
|
||||||
If a variable start to be used as default environment variable, the environment variable may have a different behavior than the expected one.
|
|
||||||
|
|
||||||
If this append, the `${{ env.GITHUB_AWESOME_VARIABLE }}` and `$GITHUB_AWESOME_VARIABLE` expression will not works in the same way.
|
|
||||||
|
|
||||||
- `${{ env.GITHUB_AWESOME_VARIABLE }}` will serve the behavior of this action,
|
|
||||||
- `$GITHUB_AWESOME_VARIABLE` will serve the behavior of GitHub Action.
|
|
||||||
|
|
||||||
Otherwise the two expression will serve the behavior of this action.
|
|
||||||
This will not occurs if you use the `prefix` input to avoid the issue.
|
|
||||||
|
|
||||||
**NOTE:** If detected, the maintainers of this action will choose the best course of action depending of the impact.
|
|
||||||
|
|
||||||
#### Known environment variable conflicts
|
|
||||||
|
|
||||||
##### GITHUB_REF_NAME
|
|
||||||
|
|
||||||
The behavior is the same as the GitHub one except on `pull_request*` workflows ([Ready the full story][issue-104]).
|
|
||||||
|
|
||||||
- `${{ env.GITHUB_REF_NAME }}` will serve the behavior of this action,
|
|
||||||
- `$GITHUB_REF_NAME` will serve the behavior of GitHub Action.
|
|
||||||
|
|
||||||
On `pull_request*` workflows, the content will be `<PR-number>/merge` instead of the branch name.
|
|
||||||
|
|
||||||
A possible workaround is to use `prefix` input
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- name: Inject slug/short variables
|
|
||||||
uses: rlespinasse/github-slug-action@v4
|
|
||||||
with:
|
|
||||||
prefix: CI_
|
|
||||||
```
|
|
||||||
|
|
||||||
Then `${{ env.CI_GITHUB_REF_NAME }}`, and `$CI_GITHUB_REF_NAME` will serve the behavior of this action.
|
|
||||||
And `$GITHUB_REF_NAME` will serve the behavior of GitHub Action.
|
|
||||||
|
|
||||||
### An action could not be found at the URI
|
|
||||||
|
|
||||||
If your workflow fail on the `Set up job` task with this kind of log
|
|
||||||
|
|
||||||
```text
|
|
||||||
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
|
|
||||||
|
|
||||||
- `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.
|
|
||||||
|
|
||||||
## Thanks for talking about us
|
## Thanks for talking about us
|
||||||
|
|
||||||
@@ -243,36 +95,34 @@ In English :gb:
|
|||||||
|
|
||||||
- [Action spotlight by Michael Heap][article-2]
|
- [Action spotlight by Michael Heap][article-2]
|
||||||
- [Serverless Deploy Previews on GitHub Actions][article-3]
|
- [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]
|
- [Let's Build a Continuous Delivery and Branching Process with GitHub Actions, Vercel and Heroku][article-4]
|
||||||
|
- [Celebrating 5 Years of github-slug-action on sfeir.dev][article-7]
|
||||||
|
|
||||||
In French :fr:
|
In French :fr:
|
||||||
|
|
||||||
- [Mettre en place une CI/CD Angular avec GitHub Actions & Netlify][article-1]
|
- [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 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:
|
In Chinese :cn:
|
||||||
|
|
||||||
- [利用github-slug-action暴漏Github Action上下文中的关键变量][article-5]
|
- [利用github-slug-action暴漏GitHub Action上下文中的关键变量][article-5]
|
||||||
|
|
||||||
> The next one is you. _Don't hesitate to add youself to one of these lists._
|
> The next one is you. _Don't hesitate to add yourself to one of these lists._
|
||||||
|
|
||||||
[examples]: https://github.com/rlespinasse/github-slug-action/tree/v4.x/examples
|
|
||||||
[custom-variable]: https://github.com/rlespinasse/github-slug-action/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=
|
[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
|
|
||||||
|
|
||||||
[git-revparse]: https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---shortlength
|
[slugify-value]: https://github.com/rlespinasse/slugify-value
|
||||||
[git-core-abbrev]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreabbrev
|
[shortify-git-revision]: https://github.com/rlespinasse/shortify-git-revision
|
||||||
|
|
||||||
[default-environment-variables]: https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
[default-environment-variables]: https://docs.github.com/en/actions/reference/workflows-and-actions/variables#default-environment-variables
|
||||||
[dependabot]: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
|
[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-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/
|
[article-2]: https://michaelheap.com/github-slug-action/
|
||||||
[article-3]: https://barstool.engineering/serverless-deploy-previews-on-github-actions/
|
[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-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-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/
|
||||||
|
[article-7]: https://www.romainlespinasse.dev/posts/celebrating-5-years-of-github-slug-action/
|
||||||
[talk-1]: https://www.youtube.com/watch?v=F5mBDmOQcvE
|
[talk-1]: https://www.youtube.com/watch?v=F5mBDmOQcvE
|
||||||
|
|||||||
17
SECURITY.md
17
SECURITY.md
@@ -4,23 +4,24 @@
|
|||||||
|
|
||||||
| Version | Supported | End of Support | Branch | Specific Tags |
|
| Version | Supported | End of Support | Branch | Specific Tags |
|
||||||
| ------- | ------------------ | -------------- | ------ | ------------- |
|
| ------- | ------------------ | -------------- | ------ | ------------- |
|
||||||
| 4.x | :white_check_mark: | | v4.x | v4 |
|
| 5.x | :white_check_mark: | | v5.x | v5 |
|
||||||
| 3.x | :white_check_mark: | 2024-01-31 | v3.x | v3 |
|
| 4.x | :x: | 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 |
|
| 2.x | :x: | 2021-04-05 | | v2.x, 2.2.0 |
|
||||||
| 1.x | :x: | 2021-04-05 | | v1.1.x, 1.2.0 |
|
| 1.x | :x: | 2021-04-05 | | v1.1.x, 1.2.0 |
|
||||||
| 1.0.x | :x: | 2019-11-07 | | 1.0.2 |
|
| 1.0.x | :x: | 2019-11-07 | | 1.0.2 |
|
||||||
|
|
||||||
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
|
### End of Life of a branch
|
||||||
|
|
||||||
Since `2023-10-20`, when a new major version is release,
|
Since `2023-10-20`, when a new major version is released,
|
||||||
|
|
||||||
- The previous one will continue to receive security patches during a 3-months periods,
|
- The previous one will continue to receive security patches for 3 months,
|
||||||
- After the 3-month periods, the branch is deleted, only the tags remains.
|
- After the 3 months, the branch is deleted, and only the tags remain.
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
You can report a Vulnerability by creating a [draft security advisory](https://github.com/rlespinasse/github-slug-action/security/advisories) in this project.
|
In this project, you can report a Vulnerability by creating a [draft security advisory](https://github.com/rlespinasse/github-slug-action/security/advisories).
|
||||||
|
|
||||||
If the vulnerability is confirm, a fix will be produce and the advisory will be publish.
|
If the vulnerability is confirmed, a fix will be produced and the advisory will be published.
|
||||||
|
|||||||
27
action.yml
27
action.yml
@@ -27,39 +27,44 @@ runs:
|
|||||||
INPUT_SHORT_LENGTH: ${{ inputs.short-length }}
|
INPUT_SHORT_LENGTH: ${{ inputs.short-length }}
|
||||||
|
|
||||||
# From Environment Variables
|
# From Environment Variables
|
||||||
- uses: rlespinasse/slugify-value@v1.4.0
|
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||||
with:
|
with:
|
||||||
key: GITHUB_REPOSITORY
|
key: GITHUB_REPOSITORY
|
||||||
value: ${{ github.repository }}
|
value: ${{ github.repository }}
|
||||||
prefix: ${{ inputs.prefix }}
|
prefix: ${{ inputs.prefix }}
|
||||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
- uses: rlespinasse/slugify-value@v1.4.0
|
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||||
with:
|
with:
|
||||||
key: GITHUB_REF
|
key: GITHUB_REF
|
||||||
prefix: ${{ inputs.prefix }}
|
prefix: ${{ inputs.prefix }}
|
||||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
- uses: rlespinasse/slugify-value@v1.4.0
|
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||||
with:
|
with:
|
||||||
key: GITHUB_HEAD_REF
|
key: GITHUB_HEAD_REF
|
||||||
prefix: ${{ inputs.prefix }}
|
prefix: ${{ inputs.prefix }}
|
||||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
- uses: rlespinasse/slugify-value@v1.4.0
|
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||||
with:
|
with:
|
||||||
key: GITHUB_BASE_REF
|
key: GITHUB_BASE_REF
|
||||||
prefix: ${{ inputs.prefix }}
|
prefix: ${{ inputs.prefix }}
|
||||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
|
|
||||||
# From Specific values
|
# From Specific values
|
||||||
- uses: rlespinasse/slugify-value@v1.4.0
|
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||||
with:
|
with:
|
||||||
key: GITHUB_EVENT_REF
|
key: GITHUB_EVENT_REF
|
||||||
value: ${{ github.event.ref }}
|
value: ${{ github.event.ref }}
|
||||||
prefix: ${{ inputs.prefix }}
|
prefix: ${{ inputs.prefix }}
|
||||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
- uses: rlespinasse/slugify-value@v1.4.0
|
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||||
with:
|
with:
|
||||||
key: GITHUB_REF_NAME
|
key: GITHUB_REF_NAME
|
||||||
# Related to https://github.com/rlespinasse/github-slug-action/issues/104
|
value: ${{ github.ref_name }}
|
||||||
|
prefix: ${{ inputs.prefix }}
|
||||||
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
|
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||||
|
with:
|
||||||
|
key: GITHUB_REF_POINT
|
||||||
value: ${{ env.GITHUB_HEAD_REF_RAW || env.GITHUB_REF_NAME_RAW }}
|
value: ${{ env.GITHUB_HEAD_REF_RAW || env.GITHUB_REF_NAME_RAW }}
|
||||||
prefix: ${{ inputs.prefix }}
|
prefix: ${{ inputs.prefix }}
|
||||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
@@ -77,7 +82,7 @@ runs:
|
|||||||
echo "::set-output name=github-repository-owner-part::${ownerpart}"
|
echo "::set-output name=github-repository-owner-part::${ownerpart}"
|
||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
- uses: rlespinasse/slugify-value@v1.4.0
|
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||||
with:
|
with:
|
||||||
key: GITHUB_REPOSITORY_OWNER_PART
|
key: GITHUB_REPOSITORY_OWNER_PART
|
||||||
value: ${{ steps.get-github-repository-owner-part.outputs.github-repository-owner-part }}
|
value: ${{ steps.get-github-repository-owner-part.outputs.github-repository-owner-part }}
|
||||||
@@ -92,7 +97,7 @@ runs:
|
|||||||
echo "::set-output name=github-repository-name-part::${namepart}"
|
echo "::set-output name=github-repository-name-part::${namepart}"
|
||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
- uses: rlespinasse/slugify-value@v1.4.0
|
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||||
with:
|
with:
|
||||||
key: GITHUB_REPOSITORY_NAME_PART
|
key: GITHUB_REPOSITORY_NAME_PART
|
||||||
value: ${{ steps.get-github-repository-name-part.outputs.github-repository-name-part }}
|
value: ${{ steps.get-github-repository-name-part.outputs.github-repository-name-part }}
|
||||||
@@ -100,13 +105,13 @@ runs:
|
|||||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
|
|
||||||
# From sha
|
# From sha
|
||||||
- uses: rlespinasse/shortify-git-revision@v1.6.0
|
- uses: rlespinasse/shortify-git-revision@c90ba7007ef6c152254d10b9f1a327966ab13077 # v1.6.0
|
||||||
with:
|
with:
|
||||||
name: GITHUB_SHA
|
name: GITHUB_SHA
|
||||||
short-on-error: true
|
short-on-error: true
|
||||||
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
|
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
|
||||||
prefix: ${{ inputs.prefix }}
|
prefix: ${{ inputs.prefix }}
|
||||||
- uses: rlespinasse/shortify-git-revision@v1.6.0
|
- uses: rlespinasse/shortify-git-revision@c90ba7007ef6c152254d10b9f1a327966ab13077 # v1.6.0
|
||||||
with:
|
with:
|
||||||
name: GITHUB_EVENT_PULL_REQUEST_HEAD_SHA
|
name: GITHUB_EVENT_PULL_REQUEST_HEAD_SHA
|
||||||
revision: ${{ github.event.pull_request.head.sha }}
|
revision: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|||||||
89
docs/explanation/slug-transformation-rules.md
Normal file
89
docs/explanation/slug-transformation-rules.md
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
# Slug Transformation Rules
|
||||||
|
|
||||||
|
This page explains the transformation algorithms used by the GitHub Slug Action, why they exist, and how they differ from each other.
|
||||||
|
|
||||||
|
## What is a "slug"?
|
||||||
|
|
||||||
|
A slug is a human-readable identifier derived from a string, safe for use in URLs, filenames, DNS labels, and other contexts where special characters are problematic. The term originates from publishing, where a "slug" is a short label used to identify a piece of content.
|
||||||
|
|
||||||
|
In CI/CD workflows, branch names, tag names, and repository names often contain characters (`/`, `@`, spaces) that break when used in URLs, Docker tags, Kubernetes labels, or file paths. Slugifying these values makes them safe for such contexts.
|
||||||
|
|
||||||
|
## SLUG transformation
|
||||||
|
|
||||||
|
The `SLUG` transformation applies the following steps in order:
|
||||||
|
|
||||||
|
1. **Lowercase** the entire string
|
||||||
|
2. **Replace** any character that is not `0-9`, `a-z`, `.`, or `_` with `-`
|
||||||
|
3. **Remove** leading `-` characters
|
||||||
|
4. **Truncate** to a maximum length (default: 63 characters)
|
||||||
|
5. **Remove** trailing `-` characters
|
||||||
|
|
||||||
|
### SLUG examples
|
||||||
|
|
||||||
|
| Input | Output |
|
||||||
|
| ----- | ------ |
|
||||||
|
| `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` |
|
||||||
|
| `octocat/Hello-World` | `octocat-hello-world` |
|
||||||
|
|
||||||
|
Note that `.` and `_` are preserved in SLUG output.
|
||||||
|
|
||||||
|
## SLUG_URL transformation
|
||||||
|
|
||||||
|
The `SLUG_URL` transformation is identical to `SLUG` except that `.` and `_` are also replaced with `-` in step 2. This makes the result safe for use as a URL path segment or subdomain label, where dots and underscores can cause issues.
|
||||||
|
|
||||||
|
### SLUG_URL examples
|
||||||
|
|
||||||
|
| Input | SLUG | SLUG_URL |
|
||||||
|
| ----- | ---- | -------- |
|
||||||
|
| `refs/tags/v1.0.0` | `v1.0.0` | `v1-0-0` |
|
||||||
|
| `rlespinasse/Hello-World.go` | `rlespinasse-hello-world.go` | `rlespinasse-hello-world-go` |
|
||||||
|
| `refs/heads/feat/new_feature` | `feat-new-feature` | `feat-new-feature` |
|
||||||
|
|
||||||
|
### When to use which
|
||||||
|
|
||||||
|
- Use **SLUG** for Docker tags, file paths, and general identifiers (dots and underscores are allowed)
|
||||||
|
- Use **SLUG_URL** for subdomains, URL path segments, and any context where dots or underscores are problematic
|
||||||
|
|
||||||
|
## Why 63 characters?
|
||||||
|
|
||||||
|
The default maximum length of 63 comes from the [DNS label length limit](https://www.rfc-editor.org/rfc/rfc1035#section-2.3.4). This is also the maximum length for:
|
||||||
|
|
||||||
|
- Kubernetes resource labels
|
||||||
|
- Many cloud provider resource names
|
||||||
|
- DNS subdomain components
|
||||||
|
|
||||||
|
You can change this limit with the `slug-maxlength` input, or set it to `"nolimit"` to disable truncation entirely.
|
||||||
|
|
||||||
|
## SHORT transformation
|
||||||
|
|
||||||
|
The `SHORT` transformation truncates Git commit SHAs to a shorter, still-unique prefix. By default, Git determines the optimal length based on your repository size using [`git rev-parse --short`][git-revparse].
|
||||||
|
|
||||||
|
| Input | Output |
|
||||||
|
| ----- | ------ |
|
||||||
|
| `ffac537e6cbbf934b08745a378932722df287a53` | `ffac537e` |
|
||||||
|
|
||||||
|
The length varies by repository because larger repositories need longer prefixes to avoid collisions. You can set a fixed length with the `short-length` input (minimum: 4).
|
||||||
|
|
||||||
|
## Case-sensitive variants (_CS)
|
||||||
|
|
||||||
|
Every `SLUG` and `SLUG_URL` variable also has a `_CS` (case-sensitive) variant that skips the lowercase step. For example:
|
||||||
|
|
||||||
|
| Input | SLUG | SLUG_CS |
|
||||||
|
| ----- | ---- | ------- |
|
||||||
|
| `refs/heads/New_Awesome_Product` | `new-awesome-product` | `New-Awesome-Product` |
|
||||||
|
|
||||||
|
This is useful when the original casing carries meaning (e.g., product names).
|
||||||
|
|
||||||
|
## PART extraction
|
||||||
|
|
||||||
|
The `PART` transformation splits a composite value and extracts a portion. Currently used for `GITHUB_REPOSITORY`:
|
||||||
|
|
||||||
|
| Input | OWNER_PART | NAME_PART |
|
||||||
|
| ----- | ---------- | --------- |
|
||||||
|
| `octocat/Hello-World` | `octocat` | `Hello-World` |
|
||||||
|
|
||||||
|
PART variables preserve the original casing. They can be further transformed using SLUG or SLUG_URL suffixes (e.g., `GITHUB_REPOSITORY_OWNER_PART_SLUG`).
|
||||||
|
|
||||||
|
[git-revparse]: https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---shortlength
|
||||||
101
docs/getting-started.md
Normal file
101
docs/getting-started.md
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
# Getting Started with GitHub Slug Action
|
||||||
|
|
||||||
|
This tutorial walks you through adding the GitHub Slug Action to a workflow and using slug variables for the first time.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- A GitHub repository with [GitHub Actions enabled](https://docs.github.com/en/actions/using-workflows)
|
||||||
|
|
||||||
|
## Step 1: Add the action to your workflow
|
||||||
|
|
||||||
|
Create or edit a workflow file (e.g., `.github/workflows/deploy.yml`) and add the action after checking out your code:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Deploy
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Inject enhanced GitHub environment variables
|
||||||
|
uses: rlespinasse/github-slug-action@v5
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> The `actions/checkout` step is recommended so that Git can determine the optimal short SHA length for your repository. It is not strictly required for slug variables.
|
||||||
|
|
||||||
|
## Step 2: Use slug variables in subsequent steps
|
||||||
|
|
||||||
|
After the action runs, all slug variables are available as environment variables. Add a step to use them:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Print slug variables
|
||||||
|
run: |
|
||||||
|
echo "Repository slug: $GITHUB_REPOSITORY_SLUG"
|
||||||
|
echo "Branch slug: $GITHUB_REF_SLUG"
|
||||||
|
echo "Short SHA: $GITHUB_SHA_SHORT"
|
||||||
|
shell: bash
|
||||||
|
```
|
||||||
|
|
||||||
|
For a branch named `feat/new_feature` on repository `octocat/Hello-World`, this outputs:
|
||||||
|
|
||||||
|
```text
|
||||||
|
Repository slug: octocat-hello-world
|
||||||
|
Branch slug: feat-new-feature
|
||||||
|
Short SHA: ffac537e
|
||||||
|
```
|
||||||
|
|
||||||
|
## Step 3: Use a slug variable for a practical purpose
|
||||||
|
|
||||||
|
A common use case is naming deployment previews with a URL-safe branch identifier:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Deploy preview
|
||||||
|
run: |
|
||||||
|
echo "Deploying to https://${GITHUB_REF_SLUG_URL}.preview.example.com"
|
||||||
|
shell: bash
|
||||||
|
```
|
||||||
|
|
||||||
|
The `SLUG_URL` variant replaces dots and underscores too, making it safe for subdomains.
|
||||||
|
|
||||||
|
## Complete workflow
|
||||||
|
|
||||||
|
Here is the full workflow file:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Deploy
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Inject enhanced GitHub environment variables
|
||||||
|
uses: rlespinasse/github-slug-action@v5
|
||||||
|
|
||||||
|
- name: Deploy preview
|
||||||
|
run: |
|
||||||
|
echo "Deploying to https://${GITHUB_REF_SLUG_URL}.preview.example.com"
|
||||||
|
echo "Commit: ${GITHUB_SHA_SHORT}"
|
||||||
|
shell: bash
|
||||||
|
```
|
||||||
|
|
||||||
|
## What you learned
|
||||||
|
|
||||||
|
- **SLUG** variables convert values to lowercase and replace special characters with `-`
|
||||||
|
- **SLUG_URL** variables also replace `.` and `_`, making values safe for URLs and subdomains
|
||||||
|
- **SHORT** variables shorten SHA commit hashes
|
||||||
|
- All variables are exposed as environment variables for use in subsequent steps
|
||||||
|
|
||||||
|
## Next steps
|
||||||
|
|
||||||
|
- [How-to guides](how-to/) for specific configuration tasks (prefixes, custom lengths, URL usage)
|
||||||
|
- [Variable reference](reference/variables.md) for the complete list of available variables
|
||||||
|
- [Slug transformation rules](explanation/slug-transformation-rules.md) to understand how transformations work
|
||||||
@@ -1,96 +1,3 @@
|
|||||||
# Available GitHub Variables
|
# Available GitHub Variables
|
||||||
|
|
||||||
All `GitHub` variables availables in your workflow in addition of ones exposed by this Action
|
This page has moved to [reference/github-variables.md](reference/github-variables.md).
|
||||||
|
|
||||||
## Table of Contents
|
|
||||||
|
|
||||||
- [Available GitHub Variables](#available-github-variables)
|
|
||||||
- [Table of Contents](#table-of-contents)
|
|
||||||
- [Default environment variables](#default-environment-variables)
|
|
||||||
- [Action-managed Environment Variables](#action-managed-environment-variables)
|
|
||||||
- [Variables from events](#variables-from-events)
|
|
||||||
- [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)
|
|
||||||
|
|
||||||
## Default environment variables
|
|
||||||
|
|
||||||
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` |
|
|
||||||
|
|
||||||
## Variables from events
|
|
||||||
|
|
||||||
Read the official documentation about [Events that trigger workflows][2].
|
|
||||||
|
|
||||||
### Action-managed Event Variables
|
|
||||||
|
|
||||||
#### create
|
|
||||||
|
|
||||||
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 |
|
|
||||||
|
|
||||||
#### 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 |
|
|
||||||
|
|
||||||
#### pull_request
|
|
||||||
|
|
||||||
Checkout [pull_request][5] webhook payload content
|
|
||||||
|
|
||||||
| 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 |
|
|
||||||
| ---------------------------------- | ---------------------------------------- |
|
|
||||||
| 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 |
|
|
||||||
| ---------------------------------- | ---------------------------------------- |
|
|
||||||
| 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 |
|
|
||||||
| ---------------------------------- | ---------------------------------------- |
|
|
||||||
| 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
|
|
||||||
[2]: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
|
|
||||||
[3]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#create
|
|
||||||
[4]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#delete
|
|
||||||
[5]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request
|
|
||||||
[6]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review
|
|
||||||
[7]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review_comment
|
|
||||||
|
|||||||
45
docs/how-to/configure-short-length.md
Normal file
45
docs/how-to/configure-short-length.md
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# Configure the length of short SHA values
|
||||||
|
|
||||||
|
Set a specific length for shortened commit SHA values instead of letting Git determine it automatically.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Inject enhanced GitHub environment variables
|
||||||
|
uses: rlespinasse/github-slug-action@v5
|
||||||
|
with:
|
||||||
|
short-length: 7
|
||||||
|
```
|
||||||
|
|
||||||
|
## Common values
|
||||||
|
|
||||||
|
| Value | Use case |
|
||||||
|
| ----- | -------- |
|
||||||
|
| _(empty)_ | Let Git decide based on repository size (default) |
|
||||||
|
| `7` | Common "small repository" length |
|
||||||
|
| `8` | Reproduce `v3` action behaviour |
|
||||||
|
| `4` | Minimum allowed length |
|
||||||
|
|
||||||
|
## Letting Git decide (default)
|
||||||
|
|
||||||
|
When `short-length` is left empty, the action uses Git's [`git rev-parse --short`][git-revparse] behaviour. The length depends on the size of your repository and may change over time as the repository grows.
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> If you leave `short-length` empty, you need to checkout the source first so Git can determine the length:
|
||||||
|
>
|
||||||
|
> ```yaml
|
||||||
|
> steps:
|
||||||
|
> - uses: actions/checkout@v6
|
||||||
|
> - uses: rlespinasse/github-slug-action@v5
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> Without a checkout step, the action falls back to the effective value of the [`core.abbrev`][git-core-abbrev] Git configuration variable, or `7` if unavailable.
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [Inputs reference](../reference/inputs.md) for the full specification
|
||||||
|
- [SHORT transformation](../explanation/slug-transformation-rules.md#short-transformation) for how short values are computed
|
||||||
|
|
||||||
|
[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
|
||||||
33
docs/how-to/configure-slug-maxlength.md
Normal file
33
docs/how-to/configure-slug-maxlength.md
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# Configure the maximum length for slug values
|
||||||
|
|
||||||
|
Change the maximum length of slugified values. The default is 63 characters (the DNS label length limit).
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Inject enhanced GitHub environment variables
|
||||||
|
uses: rlespinasse/github-slug-action@v5
|
||||||
|
with:
|
||||||
|
slug-maxlength: 80
|
||||||
|
```
|
||||||
|
|
||||||
|
## Disable the length limit
|
||||||
|
|
||||||
|
Set `slug-maxlength` to `"nolimit"` to disable truncation entirely:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Inject enhanced GitHub environment variables
|
||||||
|
uses: rlespinasse/github-slug-action@v5
|
||||||
|
with:
|
||||||
|
slug-maxlength: nolimit
|
||||||
|
```
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> The `slug-maxlength` input must not be empty. If left empty, the action will fail during preflight validation.
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [Inputs reference](../reference/inputs.md) for the full specification
|
||||||
|
- [Why 63 characters?](../explanation/slug-transformation-rules.md#why-63-characters) for the rationale behind the default
|
||||||
30
docs/how-to/migrate-v3-to-v4.md
Normal file
30
docs/how-to/migrate-v3-to-v4.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Migrate from v3 to v4
|
||||||
|
|
||||||
|
The main breaking change in v4 is that **short SHA length** is now determined by Git instead of being fixed at 8 characters.
|
||||||
|
|
||||||
|
## What changed
|
||||||
|
|
||||||
|
Since v4, Git manages the short variables using [`git rev-parse`][git-revparse] behaviour. The length of a short SHA depends on the size of your repository and can change over time as the repository grows.
|
||||||
|
|
||||||
|
## How to migrate
|
||||||
|
|
||||||
|
To reproduce the previous fixed-length behaviour, set `short-length` to `8`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Inject enhanced GitHub environment variables
|
||||||
|
uses: rlespinasse/github-slug-action@v5
|
||||||
|
with:
|
||||||
|
short-length: 8 # Same as v3 and before
|
||||||
|
```
|
||||||
|
|
||||||
|
Other options:
|
||||||
|
|
||||||
|
- Set `7` to reproduce small repository behaviour
|
||||||
|
- Leave empty to let Git decide (recommended)
|
||||||
|
|
||||||
|
> [!WARNING]
|
||||||
|
> The minimum length is `4`. The default is the effective value of the [`core.abbrev`][git-core-abbrev] Git configuration variable.
|
||||||
|
|
||||||
|
[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
|
||||||
30
docs/how-to/migrate-v4-to-v5.md
Normal file
30
docs/how-to/migrate-v4-to-v5.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Migrate from v4 to v5
|
||||||
|
|
||||||
|
The main breaking change in v5 is that **GITHUB_REF_NAME** slug variables now match GitHub's native behaviour on `pull_request*` events.
|
||||||
|
|
||||||
|
## What changed
|
||||||
|
|
||||||
|
Before v5, the action overrode `GITHUB_REF_NAME` to always contain the branch name, even on pull request events. Starting with v5, `GITHUB_REF_NAME` on pull request events contains `<PR-number>/merge` (matching GitHub's native behaviour). Read the [full story][issue-104].
|
||||||
|
|
||||||
|
## How to migrate
|
||||||
|
|
||||||
|
If you used `GITHUB_REF_NAME_SLUG` to get the branch name on pull request events, switch to `GITHUB_REF_POINT_SLUG`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Inject enhanced GitHub environment variables
|
||||||
|
uses: rlespinasse/github-slug-action@v5
|
||||||
|
- run: |
|
||||||
|
echo "Branch Name: ${GITHUB_REF_POINT}"
|
||||||
|
shell: bash
|
||||||
|
```
|
||||||
|
|
||||||
|
`GITHUB_REF_POINT` provides the branch name on pull request events (via `GITHUB_HEAD_REF`) and the ref name on all other events (via `GITHUB_REF_NAME`). All slug suffixes are available: `GITHUB_REF_POINT_SLUG`, `GITHUB_REF_POINT_SLUG_URL`, etc.
|
||||||
|
|
||||||
|
## Expression syntax
|
||||||
|
|
||||||
|
- `${{ env.GITHUB_REF_POINT }}` and `$GITHUB_REF_POINT` both serve the action's behaviour
|
||||||
|
- `${{ env.GITHUB_REF_NAME }}` serves the action's behaviour
|
||||||
|
- `$GITHUB_REF_NAME` serves GitHub Action's native behaviour
|
||||||
|
|
||||||
|
[issue-104]: https://github.com/rlespinasse/github-slug-action/issues/104
|
||||||
56
docs/how-to/troubleshooting.md
Normal file
56
docs/how-to/troubleshooting.md
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# Troubleshooting
|
||||||
|
|
||||||
|
## One of the environment variables doesn't work as intended
|
||||||
|
|
||||||
|
> [!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.**
|
||||||
|
|
||||||
|
If a variable starts to be used as a default environment variable by GitHub, the behaviour may differ depending on how you reference it:
|
||||||
|
|
||||||
|
- `${{ env.GITHUB_AWESOME_VARIABLE }}` serves the behaviour of this action
|
||||||
|
- `$GITHUB_AWESOME_VARIABLE` serves the behaviour of GitHub Actions
|
||||||
|
|
||||||
|
If both expressions return the same value, the variable is not affected. Use the [`prefix` input](use-prefix.md) to avoid this issue entirely.
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> If detected, the maintainers of this action will choose the best course of action depending on the impact.
|
||||||
|
|
||||||
|
## An action could not be found at the URI
|
||||||
|
|
||||||
|
If your workflow fails on the `Set up job` task with this kind of log:
|
||||||
|
|
||||||
|
```text
|
||||||
|
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:
|
||||||
|
|
||||||
|
- `v4.x` or after: following the [end-of-life for a branch](../../SECURITY.md#end-of-life-of-a-branch) security process, this branch may have been deleted.
|
||||||
|
- `master`: this branch no longer exists. Read more on the corresponding issue ([EOL issue][issue-15]).
|
||||||
|
|
||||||
|
Use the current **major tag** `v5` or a specific version tag (see [releases][releases]) to fix your workflow.
|
||||||
|
|
||||||
|
## Short variables are empty or have unexpected length
|
||||||
|
|
||||||
|
If `GITHUB_SHA_SHORT` is empty or shorter than expected, ensure you have checked out your repository before the action runs:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: rlespinasse/github-slug-action@v5
|
||||||
|
```
|
||||||
|
|
||||||
|
Without a checkout, Git cannot determine the optimal short length for your repository. Alternatively, set a fixed `short-length` to avoid depending on the checkout:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: rlespinasse/github-slug-action@v5
|
||||||
|
with:
|
||||||
|
short-length: 7
|
||||||
|
```
|
||||||
|
|
||||||
|
[naming-conventions]: https://docs.github.com/en/actions/reference/workflows-and-actions/variables#naming-conventions-for-configuration-variables
|
||||||
|
[default-environment-variables]: https://docs.github.com/en/actions/reference/workflows-and-actions/variables#default-environment-variables
|
||||||
|
[issue-15]: https://github.com/rlespinasse/github-slug-action/issues/15
|
||||||
|
[releases]: https://github.com/rlespinasse/github-slug-action/releases
|
||||||
26
docs/how-to/use-prefix.md
Normal file
26
docs/how-to/use-prefix.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Use a prefix for generated variables
|
||||||
|
|
||||||
|
Add a prefix to all generated environment variables to avoid naming conflicts with [GitHub's default environment variables](https://docs.github.com/en/actions/reference/workflows-and-actions/variables#default-environment-variables).
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Inject enhanced GitHub environment variables
|
||||||
|
uses: rlespinasse/github-slug-action@v5
|
||||||
|
with:
|
||||||
|
prefix: CI_
|
||||||
|
```
|
||||||
|
|
||||||
|
With this configuration, variables are named `CI_GITHUB_REPOSITORY_SLUG`, `CI_GITHUB_REF_SLUG`, `CI_GITHUB_SHA_SHORT`, etc.
|
||||||
|
|
||||||
|
## When to use a prefix
|
||||||
|
|
||||||
|
- When a variable name collides with a GitHub default environment variable (the assignment would be silently ignored without a prefix)
|
||||||
|
- When you want to distinguish slug variables from other environment variables in your workflow
|
||||||
|
- As a preventive measure against future GitHub environment variable additions
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [Inputs reference](../reference/inputs.md) for the full `prefix` input specification
|
||||||
|
- [Troubleshooting](troubleshooting.md#one-of-the-environment-variables-doesnt-work-as-intended) for details on variable name collisions
|
||||||
36
docs/how-to/use-slugs-in-urls.md
Normal file
36
docs/how-to/use-slugs-in-urls.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Use slug variables in URLs
|
||||||
|
|
||||||
|
Use `SLUG_URL` variables (not `SLUG`) when building URLs, because `SLUG_URL` also replaces dots and underscores with hyphens, making values safe for subdomains and URL paths.
|
||||||
|
|
||||||
|
## As a subdomain
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: rlespinasse/github-slug-action@v5
|
||||||
|
- run: |
|
||||||
|
./deploy-application.sh --url "https://${{ env.GITHUB_REF_SLUG_URL }}.staging.app.example.com"
|
||||||
|
```
|
||||||
|
|
||||||
|
For a branch `feat/new_feature`, this produces `https://feat-new-feature.staging.app.example.com`.
|
||||||
|
|
||||||
|
## As a URL path segment
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: rlespinasse/github-slug-action@v5
|
||||||
|
- run: |
|
||||||
|
./deploy-application.sh --url "https://staging.app.example.com/${{ env.GITHUB_REF_SLUG_URL }}"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Why SLUG_URL instead of SLUG?
|
||||||
|
|
||||||
|
The `SLUG` transformation preserves `.` and `_` characters. In a subdomain like `v1.0.0.staging.example.com`, the dots from the version tag would create invalid DNS resolution. `SLUG_URL` replaces them: `v1-0-0.staging.example.com`.
|
||||||
|
|
||||||
|
See [Slug transformation rules](../explanation/slug-transformation-rules.md#slug_url-transformation) for the full comparison.
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [Full example workflow](../../examples/url-use.yml)
|
||||||
|
- [Variable reference](../reference/variables.md) for all available `SLUG_URL` variables
|
||||||
@@ -1,28 +1,3 @@
|
|||||||
# Partial Variables
|
# Partial Variables
|
||||||
|
|
||||||
## Table of Contents
|
This page has moved to [reference/variables.md](reference/variables.md#partial-variables).
|
||||||
|
|
||||||
- [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
|
|
||||||
|
|
||||||
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_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 |
|
|
||||||
|
|||||||
87
docs/reference/github-variables.md
Normal file
87
docs/reference/github-variables.md
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
# Available GitHub Variables
|
||||||
|
|
||||||
|
All GitHub variables available in your workflow in addition to ones exposed by this action.
|
||||||
|
|
||||||
|
## Default Environment Variables
|
||||||
|
|
||||||
|
Read the official documentation about [Default environment variables][1].
|
||||||
|
|
||||||
|
### Action-managed Environment Variables
|
||||||
|
|
||||||
|
| Action-managed Variables | Can be suffixed 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
|
||||||
|
|
||||||
|
Read the official documentation about [Events that trigger workflows][2].
|
||||||
|
|
||||||
|
### Action-managed Event Variables
|
||||||
|
|
||||||
|
#### create
|
||||||
|
|
||||||
|
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 |
|
||||||
|
|
||||||
|
#### 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 |
|
||||||
|
|
||||||
|
#### pull_request
|
||||||
|
|
||||||
|
Checkout [pull_request][5] webhook payload content
|
||||||
|
|
||||||
|
| 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 |
|
||||||
|
| ------------------------ | ------------ |
|
||||||
|
| 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 |
|
||||||
|
| ------------------------ | ------------ |
|
||||||
|
| 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 |
|
||||||
|
| ------------------------ | ------------ |
|
||||||
|
| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT |
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [Variable reference](variables.md) for transformation examples
|
||||||
|
- [Slug transformation rules](../explanation/slug-transformation-rules.md) for how transformations work
|
||||||
|
|
||||||
|
[1]: https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
|
||||||
|
[2]: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
|
||||||
|
[3]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#create
|
||||||
|
[4]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#delete
|
||||||
|
[5]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request
|
||||||
|
[6]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review
|
||||||
|
[7]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#pull_request_review_comment
|
||||||
23
docs/reference/inputs.md
Normal file
23
docs/reference/inputs.md
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Inputs Reference
|
||||||
|
|
||||||
|
The GitHub Slug Action accepts the following inputs in the `with:` block.
|
||||||
|
|
||||||
|
| Input | Required | Default | Description |
|
||||||
|
| ----- | -------- | ------- | ----------- |
|
||||||
|
| `prefix` | No | `""` | Value prepended to each generated variable name. For example, `prefix: CI_` produces `CI_GITHUB_REPOSITORY_SLUG` instead of `GITHUB_REPOSITORY_SLUG`. |
|
||||||
|
| `slug-maxlength` | Yes | `63` | Maximum length of slugified values. Accepts a number or `"nolimit"` to disable truncation. Must not be empty. |
|
||||||
|
| `short-length` | No | _(Git default)_ | Length of shortened SHA values. Minimum `4`. When empty, Git determines the length based on your repository size using [`git rev-parse`][git-revparse]. |
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- When `short-length` is left empty, the action uses the effective value of the [`core.abbrev`][git-core-abbrev] Git configuration variable. This requires your repository to be checked out first (via `actions/checkout`).
|
||||||
|
- The `slug-maxlength` default of `63` matches the DNS label length limit, which is also the maximum length for Kubernetes labels.
|
||||||
|
|
||||||
|
## See also
|
||||||
|
|
||||||
|
- [How to use a prefix](../how-to/use-prefix.md)
|
||||||
|
- [How to configure slug max length](../how-to/configure-slug-maxlength.md)
|
||||||
|
- [How to configure short length](../how-to/configure-short-length.md)
|
||||||
|
|
||||||
|
[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
|
||||||
312
docs/reference/variables.md
Normal file
312
docs/reference/variables.md
Normal file
@@ -0,0 +1,312 @@
|
|||||||
|
# Variable Reference
|
||||||
|
|
||||||
|
Complete reference for all environment variables generated by the GitHub Slug Action.
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> All slug and slug-url variables are also available in case-sensitive (`_CS`) variants. See [Case-sensitive variants](#case-sensitive-variants).
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
| Variable | Type | Description |
|
||||||
|
| -------- | ---- | ----------- |
|
||||||
|
| `GITHUB_REF_POINT` | Enhanced | Branch or tag name (consistent across event types) |
|
||||||
|
| `GITHUB_REPOSITORY_OWNER_PART` | Partial | Owner extracted from `GITHUB_REPOSITORY` |
|
||||||
|
| `GITHUB_REPOSITORY_NAME_PART` | Partial | Repository name extracted from `GITHUB_REPOSITORY` |
|
||||||
|
| `GITHUB_REPOSITORY_SLUG` | Slug | Slugified owner/repository name |
|
||||||
|
| `GITHUB_REPOSITORY_OWNER_PART_SLUG` | Slug | Slugified owner name |
|
||||||
|
| `GITHUB_REPOSITORY_NAME_PART_SLUG` | Slug | Slugified repository name |
|
||||||
|
| `GITHUB_REF_SLUG` | Slug | Slugified branch or tag ref |
|
||||||
|
| `GITHUB_REF_NAME_SLUG` | Slug | Slugified branch or tag name |
|
||||||
|
| `GITHUB_HEAD_REF_SLUG` | Slug | Slugified PR head branch |
|
||||||
|
| `GITHUB_BASE_REF_SLUG` | Slug | Slugified PR base branch |
|
||||||
|
| `GITHUB_EVENT_REF_SLUG` | Slug | Slugified webhook ref |
|
||||||
|
| `GITHUB_REPOSITORY_SLUG_URL` | Slug URL | URL-safe owner/repository name |
|
||||||
|
| `GITHUB_REPOSITORY_OWNER_PART_SLUG_URL` | Slug URL | URL-safe owner name |
|
||||||
|
| `GITHUB_REPOSITORY_NAME_PART_SLUG_URL` | Slug URL | URL-safe repository name |
|
||||||
|
| `GITHUB_REF_SLUG_URL` | Slug URL | URL-safe branch or tag ref |
|
||||||
|
| `GITHUB_REF_NAME_SLUG_URL` | Slug URL | URL-safe branch or tag name |
|
||||||
|
| `GITHUB_HEAD_REF_SLUG_URL` | Slug URL | URL-safe PR head branch |
|
||||||
|
| `GITHUB_BASE_REF_SLUG_URL` | Slug URL | URL-safe PR base branch |
|
||||||
|
| `GITHUB_EVENT_REF_SLUG_URL` | Slug URL | URL-safe webhook ref |
|
||||||
|
| `GITHUB_SHA_SHORT` | Short | Shortened commit SHA |
|
||||||
|
| `GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT` | Short | Shortened PR head commit SHA |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Enhanced Variables
|
||||||
|
|
||||||
|
### GITHUB_REF_POINT
|
||||||
|
|
||||||
|
The reference name (branch or tag), consistent across all event types:
|
||||||
|
|
||||||
|
- Uses `GITHUB_HEAD_REF` in [`pull_request*`][webhooks] event contexts
|
||||||
|
- Uses `GITHUB_REF_NAME` in all other event contexts
|
||||||
|
|
||||||
|
This provides a stable branch name regardless of event type. On pull request events, `GITHUB_REF_NAME` contains `<PR#>/merge`, while `GITHUB_REF_POINT` contains the actual branch name.
|
||||||
|
|
||||||
|
Available with all slug suffixes: `GITHUB_REF_POINT_SLUG`, `GITHUB_REF_POINT_SLUG_URL`, `GITHUB_REF_POINT_SLUG_CS`, `GITHUB_REF_POINT_SLUG_URL_CS`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Partial Variables
|
||||||
|
|
||||||
|
### 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_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 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Slug Variables
|
||||||
|
|
||||||
|
Slug variables apply the [SLUG transformation](../explanation/slug-transformation-rules.md#slug-transformation): lowercase, replace special characters with `-`, preserve `.` and `_`, truncate to max length.
|
||||||
|
|
||||||
|
### GITHUB_REPOSITORY_SLUG
|
||||||
|
|
||||||
|
Slug of **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 |
|
||||||
|
| AnotherPerson/SomeRepository | anotherperson-somerepository |
|
||||||
|
|
||||||
|
### GITHUB_REPOSITORY_OWNER_PART_SLUG
|
||||||
|
|
||||||
|
Slug of **GITHUB_REPOSITORY_OWNER_PART** -- the owner name.
|
||||||
|
|
||||||
|
| GITHUB_REPOSITORY_OWNER_PART | GITHUB_REPOSITORY_OWNER_PART_SLUG |
|
||||||
|
| ---------------------------- | --------------------------------- |
|
||||||
|
| octocat | octocat |
|
||||||
|
| rlespinasse | rlespinasse |
|
||||||
|
| AnotherPerson | anotherperson |
|
||||||
|
|
||||||
|
### GITHUB_REPOSITORY_NAME_PART_SLUG
|
||||||
|
|
||||||
|
Slug of **GITHUB_REPOSITORY_NAME_PART** -- the repository name.
|
||||||
|
|
||||||
|
| GITHUB_REPOSITORY_NAME_PART | GITHUB_REPOSITORY_NAME_PART_SLUG |
|
||||||
|
| --------------------------- | -------------------------------- |
|
||||||
|
| Hello-World | hello-world |
|
||||||
|
| Hello-World.go | hello-world.go |
|
||||||
|
| SomeRepository | somerepository |
|
||||||
|
|
||||||
|
### GITHUB_REF_SLUG
|
||||||
|
|
||||||
|
Slug of **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 |
|
||||||
|
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
### GITHUB_REF_NAME_SLUG
|
||||||
|
|
||||||
|
Slug of **GITHUB_REF_NAME** -- the branch or tag name shown on GitHub.
|
||||||
|
_If neither a branch or tag is available for the event type, the variable will not exist._
|
||||||
|
|
||||||
|
| GITHUB_REF_NAME | GITHUB_REF_NAME_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 of **GITHUB_HEAD_REF** -- the branch of the head repository.
|
||||||
|
_Only set for [`pull_request*`][webhooks] events and forked repositories._
|
||||||
|
|
||||||
|
| GITHUB_HEAD_REF | GITHUB_HEAD_REF_SLUG |
|
||||||
|
| --------------- | -------------------- |
|
||||||
|
| main | main |
|
||||||
|
| feat/new_feature | feat-new-feature |
|
||||||
|
| New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
### GITHUB_BASE_REF_SLUG
|
||||||
|
|
||||||
|
Slug of **GITHUB_BASE_REF** -- the branch of the base repository.
|
||||||
|
_Only set for [`pull_request*`][webhooks] events and forked repositories._
|
||||||
|
|
||||||
|
| GITHUB_BASE_REF | GITHUB_BASE_REF_SLUG |
|
||||||
|
| --------------- | -------------------- |
|
||||||
|
| main | main |
|
||||||
|
| feat/new_feature | feat-new-feature |
|
||||||
|
| New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
### GITHUB_EVENT_REF_SLUG
|
||||||
|
|
||||||
|
Slug of **github.event.ref** -- the Git reference resource associated to the triggered webhook.
|
||||||
|
_Only set for [`create` and `delete`][webhooks] events._
|
||||||
|
|
||||||
|
| github.event.ref | GITHUB_EVENT_REF_SLUG |
|
||||||
|
| ---------------- | --------------------- |
|
||||||
|
| main | main |
|
||||||
|
| feat/new_feature | feat-new-feature |
|
||||||
|
| New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## URL-Safe Slug Variables
|
||||||
|
|
||||||
|
URL-safe slug variables apply the [SLUG_URL transformation](../explanation/slug-transformation-rules.md#slug_url-transformation): same as SLUG but `.` and `_` are also replaced with `-`.
|
||||||
|
|
||||||
|
### GITHUB_REPOSITORY_SLUG_URL
|
||||||
|
|
||||||
|
URL-safe slug of **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 |
|
||||||
|
| AnotherPerson/SomeRepository | anotherperson-somerepository |
|
||||||
|
|
||||||
|
### GITHUB_REPOSITORY_OWNER_PART_SLUG_URL
|
||||||
|
|
||||||
|
URL-safe slug of **GITHUB_REPOSITORY_OWNER_PART** -- the owner name.
|
||||||
|
|
||||||
|
| GITHUB_REPOSITORY_OWNER_PART | GITHUB_REPOSITORY_OWNER_PART_SLUG_URL |
|
||||||
|
| ---------------------------- | ------------------------------------- |
|
||||||
|
| octocat | octocat |
|
||||||
|
| rlespinasse | rlespinasse |
|
||||||
|
| AnotherPerson | anotherperson |
|
||||||
|
|
||||||
|
### GITHUB_REPOSITORY_NAME_PART_SLUG_URL
|
||||||
|
|
||||||
|
URL-safe slug of **GITHUB_REPOSITORY_NAME_PART** -- the repository name.
|
||||||
|
|
||||||
|
| GITHUB_REPOSITORY_NAME_PART | GITHUB_REPOSITORY_NAME_PART_SLUG_URL |
|
||||||
|
| --------------------------- | ------------------------------------ |
|
||||||
|
| Hello-World | hello-world |
|
||||||
|
| Hello-World.go | hello-world-go |
|
||||||
|
| SomeRepository | somerepository |
|
||||||
|
|
||||||
|
### GITHUB_REF_SLUG_URL
|
||||||
|
|
||||||
|
URL-safe slug of **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 |
|
||||||
|
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
### GITHUB_REF_NAME_SLUG_URL
|
||||||
|
|
||||||
|
URL-safe slug of **GITHUB_REF_NAME** -- the branch or tag name shown on GitHub.
|
||||||
|
_If neither a branch or tag is available for the event type, the variable will not exist._
|
||||||
|
|
||||||
|
| GITHUB_REF_NAME | GITHUB_REF_NAME_SLUG_URL |
|
||||||
|
| --------------- | ------------------------ |
|
||||||
|
| main | main |
|
||||||
|
| feat/new_feature | feat-new-feature |
|
||||||
|
| v1.0.0 | v1-0-0 |
|
||||||
|
| 42/merge | 42-merge |
|
||||||
|
| product@1.0.0-rc.2 | product-1-0-0-rc-2 |
|
||||||
|
| New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
### GITHUB_HEAD_REF_SLUG_URL
|
||||||
|
|
||||||
|
URL-safe slug of **GITHUB_HEAD_REF** -- the branch of the head repository.
|
||||||
|
_Only set for [`pull_request*`][webhooks] events and forked repositories._
|
||||||
|
|
||||||
|
| GITHUB_HEAD_REF | GITHUB_HEAD_REF_SLUG_URL |
|
||||||
|
| --------------- | ------------------------ |
|
||||||
|
| main | main |
|
||||||
|
| feat/new_feature | feat-new-feature |
|
||||||
|
| New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
### GITHUB_BASE_REF_SLUG_URL
|
||||||
|
|
||||||
|
URL-safe slug of **GITHUB_BASE_REF** -- the branch of the base repository.
|
||||||
|
_Only set for [`pull_request*`][webhooks] events and forked repositories._
|
||||||
|
|
||||||
|
| GITHUB_BASE_REF | GITHUB_BASE_REF_SLUG_URL |
|
||||||
|
| --------------- | ------------------------ |
|
||||||
|
| main | main |
|
||||||
|
| feat/new_feature | feat-new-feature |
|
||||||
|
| New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
### GITHUB_EVENT_REF_SLUG_URL
|
||||||
|
|
||||||
|
URL-safe slug of **github.event.ref** -- the Git reference resource associated to the triggered webhook.
|
||||||
|
_Only set for [`create` and `delete`][webhooks] events._
|
||||||
|
|
||||||
|
| github.event.ref | GITHUB_EVENT_REF_SLUG_URL |
|
||||||
|
| ---------------- | ------------------------- |
|
||||||
|
| main | main |
|
||||||
|
| feat/new_feature | feat-new-feature |
|
||||||
|
| New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Short Variables
|
||||||
|
|
||||||
|
### GITHUB_SHA_SHORT
|
||||||
|
|
||||||
|
Shortened **GITHUB_SHA** -- the commit SHA that triggered the workflow.
|
||||||
|
|
||||||
|
| GITHUB_SHA | GITHUB_SHA_SHORT |
|
||||||
|
| ---------- | ---------------- |
|
||||||
|
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
|
||||||
|
|
||||||
|
### GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT
|
||||||
|
|
||||||
|
Shortened value of `github.event.pull_request.head.sha` -- the last commit on the pull request that triggered the workflow.
|
||||||
|
|
||||||
|
| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT |
|
||||||
|
| ---------------------------------- | ---------------------------------------- |
|
||||||
|
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Case-Sensitive Variants
|
||||||
|
|
||||||
|
All slug and slug-url variables have a `_CS` suffix variant that preserves the original casing. The `_CS` variant applies the same transformation but skips the lowercase step.
|
||||||
|
|
||||||
|
| Standard | Case-Sensitive |
|
||||||
|
| -------- | -------------- |
|
||||||
|
| `GITHUB_REPOSITORY_SLUG` | `GITHUB_REPOSITORY_SLUG_CS` |
|
||||||
|
| `GITHUB_REPOSITORY_SLUG_URL` | `GITHUB_REPOSITORY_SLUG_URL_CS` |
|
||||||
|
| `GITHUB_REF_SLUG` | `GITHUB_REF_SLUG_CS` |
|
||||||
|
| `GITHUB_REF_SLUG_URL` | `GITHUB_REF_SLUG_URL_CS` |
|
||||||
|
| _(and so on for all slug/slug-url variables)_ | |
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
| Input | SLUG | SLUG_CS |
|
||||||
|
| ----- | ---- | ------- |
|
||||||
|
| `refs/heads/New_Awesome_Product` | `new-awesome-product` | `New-Awesome-Product` |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Variable Availability by Event
|
||||||
|
|
||||||
|
Not all variables are set for every event type. See [GitHub variables by event](github-variables.md) for the full matrix.
|
||||||
|
|
||||||
|
[webhooks]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads
|
||||||
@@ -1,27 +1,3 @@
|
|||||||
# Short Variables
|
# Short Variables
|
||||||
|
|
||||||
## Table of Contents
|
This page has moved to [reference/variables.md](reference/variables.md#short-variables).
|
||||||
|
|
||||||
- [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
|
|
||||||
|
|
||||||
Short the environment variable **GITHUB_SHA**
|
|
||||||
|
|
||||||
The commit SHA that triggered the workflow
|
|
||||||
|
|
||||||
| 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 |
|
|
||||||
|
|||||||
@@ -1,109 +1,3 @@
|
|||||||
# Slug URL Variables
|
# Slug URL Variables
|
||||||
|
|
||||||
## Table of Contents
|
This page has moved to [reference/variables.md](reference/variables.md#url-safe-slug-variables).
|
||||||
|
|
||||||
- [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
|
|
||||||
|
|
||||||
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 |
|
|
||||||
| AnotherPerson/SomeRepository | anotherperson-somerepository |
|
|
||||||
|
|
||||||
## GITHUB_REPOSITORY_OWNER_PART_SLUG_URL
|
|
||||||
|
|
||||||
Slug URL the environment variable [GITHUB_REPOSITORY_OWNER_PART](partial-variables.md#github_repository_owner_part)
|
|
||||||
|
|
||||||
The Owner part of **GITHUB_REPOSITORY** variable.
|
|
||||||
|
|
||||||
| GITHUB_REPOSITORY_OWNER_PART | GITHUB_REPOSITORY_OWNER_PART_SLUG_URL |
|
|
||||||
| ---------------------------- | ------------------------------------- |
|
|
||||||
| octocat | octocat |
|
|
||||||
| rlespinasse | rlespinasse |
|
|
||||||
| AnotherPerson | anotherperson |
|
|
||||||
|
|
||||||
## GITHUB_REPOSITORY_NAME_PART_SLUG_URL
|
|
||||||
|
|
||||||
Slug URL the environment variable [GITHUB_REPOSITORY_NAME_PART](partial-variables.md#github_repository_name_part)
|
|
||||||
|
|
||||||
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 |
|
|
||||||
|
|
||||||
## GITHUB_REF_SLUG_URL
|
|
||||||
|
|
||||||
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 |
|
|
||||||
| 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_HEAD_REF_SLUG_URL
|
|
||||||
|
|
||||||
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_BASE_REF_SLUG_URL
|
|
||||||
|
|
||||||
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_EVENT_REF_SLUG_URL
|
|
||||||
|
|
||||||
Slug URL the variable **github.event.ref**
|
|
||||||
|
|
||||||
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 |
|
|
||||||
|
|
||||||
[1]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads
|
|
||||||
|
|||||||
@@ -1,105 +1,3 @@
|
|||||||
# Slug Variables
|
# Slug Variables
|
||||||
|
|
||||||
## Table of Contents
|
This page has moved to [reference/variables.md](reference/variables.md#slug-variables).
|
||||||
|
|
||||||
- [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
|
|
||||||
|
|
||||||
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 |
|
|
||||||
| AnotherPerson/SomeRepository | anotherperson-somerepository |
|
|
||||||
|
|
||||||
## GITHUB_REPOSITORY_OWNER_PART_SLUG
|
|
||||||
|
|
||||||
Slug the environment variable [GITHUB_REPOSITORY_OWNER_PART](partial-variables.md#github_repository_owner_part)
|
|
||||||
|
|
||||||
The Owner part of **GITHUB_REPOSITORY** variable.
|
|
||||||
|
|
||||||
| GITHUB_REPOSITORY_OWNER_PART | GITHUB_REPOSITORY_OWNER_PART_SLUG |
|
|
||||||
| ---------------------------- | --------------------------------- |
|
|
||||||
| octocat | octocat |
|
|
||||||
| rlespinasse | rlespinasse |
|
|
||||||
| AnotherPerson | anotherperson |
|
|
||||||
|
|
||||||
## GITHUB_REPOSITORY_NAME_PART_SLUG
|
|
||||||
|
|
||||||
Slug the environment variable [GITHUB_REPOSITORY_NAME_PART](partial-variables.md#github_repository_name_part)
|
|
||||||
|
|
||||||
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 |
|
|
||||||
|
|
||||||
## GITHUB_REF_SLUG
|
|
||||||
|
|
||||||
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 |
|
|
||||||
| refs/heads/New_Awesome_Product | new-awesome-product |
|
|
||||||
|
|
||||||
## GITHUB_HEAD_REF_SLUG
|
|
||||||
|
|
||||||
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_BASE_REF_SLUG
|
|
||||||
|
|
||||||
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_EVENT_REF_SLUG
|
|
||||||
|
|
||||||
Slug the variable **github.event.ref**
|
|
||||||
|
|
||||||
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 |
|
|
||||||
|
|
||||||
[1]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ jobs:
|
|||||||
usage:
|
usage:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v6
|
||||||
- uses: rlespinasse/github-slug-action@v4
|
- uses: rlespinasse/github-slug-action@v5
|
||||||
- name: Output
|
- name: Output
|
||||||
run: |
|
run: |
|
||||||
echo "Partial variables"
|
echo "Partial variables"
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ jobs:
|
|||||||
usage:
|
usage:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v6
|
||||||
- uses: rlespinasse/github-slug-action@v4
|
- uses: rlespinasse/github-slug-action@v5
|
||||||
- name: Output
|
- name: Output
|
||||||
run: |
|
run: |
|
||||||
echo "Partial variables"
|
echo "Partial variables"
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ jobs:
|
|||||||
as_subdomain:
|
as_subdomain:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v6
|
||||||
- uses: rlespinasse/github-slug-action@v4
|
- uses: rlespinasse/github-slug-action@v5
|
||||||
- run: |
|
- run: |
|
||||||
./deploy-application.sh --url "https://${{ env.GITHUB_REF_SLUG_URL }}.staging.app.example.com"
|
./deploy-application.sh --url "https://${{ env.GITHUB_REF_SLUG_URL }}.staging.app.example.com"
|
||||||
|
|
||||||
as_resource_path:
|
as_resource_path:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v6
|
||||||
- uses: rlespinasse/github-slug-action@v4
|
- uses: rlespinasse/github-slug-action@v5
|
||||||
- run: |
|
- run: |
|
||||||
./deploy-application.sh --url "https://staging.app.example.com/${{ env.GITHUB_REF_SLUG_URL }}"
|
./deploy-application.sh --url "https://staging.app.example.com/${{ env.GITHUB_REF_SLUG_URL }}"
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ jobs:
|
|||||||
usage:
|
usage:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v6
|
||||||
- uses: rlespinasse/github-slug-action@v4
|
- uses: rlespinasse/github-slug-action@v5
|
||||||
- name: Output
|
- name: Output
|
||||||
run: |
|
run: |
|
||||||
echo "Partial variables"
|
echo "Partial variables"
|
||||||
|
|||||||
Reference in New Issue
Block a user