mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-05-18 12:41:46 +00:00
Compare commits
124 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e7def6155 | ||
|
|
e8d233181c | ||
|
|
6f7a8d2348 | ||
|
|
ac4a3a2668 | ||
|
|
6772bda8f6 | ||
|
|
846af0aca2 | ||
|
|
c33ff65466 | ||
|
|
50025f78ad | ||
|
|
8e1194b8b1 | ||
|
|
fe13438220 | ||
|
|
810e74b089 | ||
|
|
26e0654625 | ||
|
|
955b5ba456 | ||
|
|
ba00826602 | ||
|
|
797666298f | ||
|
|
56d132125c | ||
|
|
aba9f8db6e | ||
|
|
63a442f83b | ||
|
|
c6c92fed42 | ||
|
|
7c4f489627 | ||
|
|
45c9d47db8 | ||
|
|
797d688647 | ||
|
|
55f5982579 | ||
|
|
5ee5b39fa5 | ||
|
|
399f2aa780 | ||
|
|
87a6de197b | ||
|
|
6e13412dd5 | ||
|
|
00d4236bb3 | ||
|
|
e5042e702f | ||
|
|
d1ca8ffbce | ||
|
|
094dd7fdb3 | ||
|
|
4bf56f04ea | ||
|
|
552f3c0362 | ||
|
|
102b1a064a | ||
|
|
a362e5fb42 | ||
|
|
b011e83cf8 | ||
|
|
00198f8992 | ||
|
|
9c3571fd3d | ||
|
|
0141d9b38d | ||
|
|
33cd7a701d | ||
|
|
2c5a627861 | ||
|
|
aa95092e35 | ||
|
|
1615fcb48b | ||
|
|
812bd42f94 | ||
|
|
6839855732 | ||
|
|
53459a86e2 | ||
|
|
4177734b38 | ||
|
|
ad808ea8b2 | ||
|
|
7a3b4c1766 | ||
|
|
dbbe21b72b | ||
|
|
88f3ee8f6f | ||
|
|
cd9871b66e | ||
|
|
1fb0eeb01e | ||
|
|
bd31a9f564 | ||
|
|
78ed3f92ee | ||
|
|
c1ec67827c | ||
|
|
e91720375f | ||
|
|
e13c7fcc34 | ||
|
|
4405613430 | ||
|
|
5d786b4cd2 | ||
|
|
ba2cfdae8a | ||
|
|
200b9d942b | ||
|
|
046be07299 | ||
|
|
38b80287e3 | ||
|
|
c559dac9da | ||
|
|
2f05f8b5cb | ||
|
|
9f53b89c13 | ||
|
|
172fe43594 | ||
|
|
12a7510630 | ||
|
|
b71a8a1cbc | ||
|
|
54910e921d | ||
|
|
35d90c4a71 | ||
|
|
ada34a0888 | ||
|
|
6370faccb7 | ||
|
|
81beb28f90 | ||
|
|
08cd74e0fa | ||
|
|
8c0a3268b6 | ||
|
|
016823880d | ||
|
|
e6c550f88c | ||
|
|
4060fda269 | ||
|
|
475d293680 | ||
|
|
0c099abd97 | ||
|
|
6c93fcbf53 | ||
|
|
38c43d3f60 | ||
|
|
275eb0d01d | ||
|
|
d1880ea5b3 | ||
|
|
66299f72e4 | ||
|
|
78985f84ec | ||
|
|
75ce03b6a0 | ||
|
|
49e1056c70 | ||
|
|
81bff0391a | ||
|
|
b956e16ac2 | ||
|
|
fad587c035 | ||
|
|
5f4806451f | ||
|
|
c8d8ee50d0 | ||
|
|
5b9fe6015d | ||
|
|
5629d21ee9 | ||
|
|
b6938fb2bd | ||
|
|
d6257a36a9 | ||
|
|
7ad978282a | ||
|
|
9f5fafb8ad | ||
|
|
750d2f7f48 | ||
|
|
2b1034b1fb | ||
|
|
1b1913be6c | ||
|
|
cc560ad7b4 | ||
|
|
549c11b4e2 | ||
|
|
68eb43656c | ||
|
|
2aba10a826 | ||
|
|
afcda09378 | ||
|
|
15f6edebdd | ||
|
|
e4699e49fc | ||
|
|
3cddc4f12d | ||
|
|
d7817bf204 | ||
|
|
4e3f956c5e | ||
|
|
f79727b5cc | ||
|
|
a3c7c5c7a1 | ||
|
|
008aa6260d | ||
|
|
3c7ae42a01 | ||
|
|
ae2430ad57 | ||
|
|
6a873bec5a | ||
|
|
749009dfe1 | ||
|
|
ec03dc4d9c | ||
|
|
d0549c1f85 | ||
|
|
13c2f38dad |
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* @rlespinasse
|
||||
23
.github/dependabot.yml
vendored
Normal file
23
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: 'github-actions'
|
||||
directory: '/.github/'
|
||||
schedule:
|
||||
interval: 'weekly'
|
||||
groups:
|
||||
dependencies:
|
||||
patterns:
|
||||
- '*'
|
||||
labels: []
|
||||
- package-ecosystem: 'github-actions'
|
||||
directory: '/'
|
||||
commit-message:
|
||||
prefix: 'feat: '
|
||||
schedule:
|
||||
interval: 'weekly'
|
||||
groups:
|
||||
dependencies:
|
||||
patterns:
|
||||
- 'rlespinasse/slugify-value'
|
||||
- 'rlespinasse/shortify-git-revision'
|
||||
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@v8
|
||||
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
|
||||
23
.github/workflows/ci.yml
vendored
23
.github/workflows/ci.yml
vendored
@@ -1,23 +0,0 @@
|
||||
name: Build
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: docker://ffurrer/bats:latest
|
||||
with:
|
||||
args: "--recursive ."
|
||||
- uses: cycjimmy/semantic-release-action@v2
|
||||
with:
|
||||
semantic_version: 17.0.7
|
||||
branches: |
|
||||
[
|
||||
'v1.1.x',
|
||||
'v2.x'
|
||||
]
|
||||
extra_plugins: |
|
||||
@semantic-release/changelog@5.0.1
|
||||
@semantic-release/git@9.0.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||
32
.github/workflows/linter.yml
vendored
Normal file
32
.github/workflows/linter.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
---
|
||||
name: Lint Code Base
|
||||
|
||||
on: pull_request
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Lint Code Base
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
statuses: write
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
# Full git history is needed to get a proper
|
||||
# list of changed files within `super-linter`
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Lint Code Base
|
||||
uses: super-linter/super-linter@v8
|
||||
env:
|
||||
VALIDATE_ALL_CODEBASE: false
|
||||
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
|
||||
VALIDATE_JSCPD: false
|
||||
VALIDATE_MARKDOWN_PRETTIER: false
|
||||
VALIDATE_YAML_PRETTIER: false
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
402
.github/workflows/v5-tests-and-release.yml
vendored
Normal file
402
.github/workflows/v5-tests-and-release.yml
vendored
Normal file
@@ -0,0 +1,402 @@
|
||||
name: "[v5] Test and Release"
|
||||
on: [push, pull_request]
|
||||
permissions: read-all
|
||||
jobs:
|
||||
check-v4-compatibility:
|
||||
name: "Check v4 compatibility"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Load this action from HEAD
|
||||
uses: ./
|
||||
|
||||
- name: Load using v4
|
||||
uses: rlespinasse/github-slug-action@v4
|
||||
with:
|
||||
prefix: V4_
|
||||
|
||||
- name: Validate // Partial variables
|
||||
run: |
|
||||
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART }}" ]]
|
||||
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART }}" ]]
|
||||
shell: bash
|
||||
|
||||
- name: Validate // Slug variables
|
||||
run: |
|
||||
[[ "${{ env.GITHUB_REPOSITORY_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG }}" ]]
|
||||
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG }}" ]]
|
||||
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG }}" ]]
|
||||
[[ "${{ env.GITHUB_REF_SLUG }}" == "${{ env.V4_GITHUB_REF_SLUG }}" ]]
|
||||
[[ "${{ env.GITHUB_HEAD_REF_SLUG }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG }}" ]]
|
||||
[[ "${{ env.GITHUB_BASE_REF_SLUG }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG }}" ]]
|
||||
[[ "${{ env.GITHUB_EVENT_REF_SLUG }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG }}" ]]
|
||||
shell: bash
|
||||
- name: Validate // Slug variables (Case Sensitive)
|
||||
run: |
|
||||
[[ "${{ env.GITHUB_REPOSITORY_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_SLUG_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_HEAD_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_BASE_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_EVENT_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_CS }}" ]]
|
||||
shell: bash
|
||||
- name: Validate // Slug URL variables
|
||||
run: |
|
||||
[[ "${{ env.GITHUB_REPOSITORY_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_URL }}" ]]
|
||||
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" ]]
|
||||
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" ]]
|
||||
[[ "${{ env.GITHUB_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_SLUG_URL }}" ]]
|
||||
[[ "${{ env.GITHUB_HEAD_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_URL }}" ]]
|
||||
[[ "${{ env.GITHUB_BASE_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_URL }}" ]]
|
||||
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL }}" ]]
|
||||
shell: bash
|
||||
- name: Validate // Slug URL variables (Case Sensitive)
|
||||
run: |
|
||||
[[ "${{ env.GITHUB_REPOSITORY_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_URL_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_SLUG_URL_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_HEAD_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_URL_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_URL_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL_CS }}" ]]
|
||||
shell: bash
|
||||
|
||||
- name: Validate // Ref Point
|
||||
run: |
|
||||
[[ "${{ env.GITHUB_REF_POINT }}" == "${{ env.V4_GITHUB_REF_NAME }}" ]]
|
||||
[[ "${{ env.GITHUB_REF_POINT_SLUG }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG }}" ]]
|
||||
[[ "${{ env.GITHUB_REF_POINT_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL }}" ]]
|
||||
[[ "${{ env.GITHUB_REF_POINT_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_CS }}" ]]
|
||||
[[ "${{ env.GITHUB_REF_POINT_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL_CS }}" ]]
|
||||
shell: bash
|
||||
|
||||
- name: Validate // Short SHA variables
|
||||
run: |
|
||||
[[ "${{ env.GITHUB_SHA_SHORT }}" == "${{ env.V4_GITHUB_SHA_SHORT }}" ]]
|
||||
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
|
||||
shell: bash
|
||||
|
||||
check-v4-compatibility-without-checkout:
|
||||
name: "Check v4 compatibility (without checkout)"
|
||||
needs:
|
||||
- check-v4-compatibility
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
path: this-action
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
- name: Load this action from HEAD
|
||||
uses: ./this-action
|
||||
|
||||
- name: Load using v4
|
||||
uses: rlespinasse/github-slug-action@v4
|
||||
with:
|
||||
prefix: V4_
|
||||
|
||||
- name: Validate // Short SHA variables
|
||||
run: |
|
||||
[[ "${{ env.GITHUB_SHA_SHORT }}" == "${{ env.V4_GITHUB_SHA_SHORT }}" ]]
|
||||
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
|
||||
shell: bash
|
||||
|
||||
display:
|
||||
name: "Display produced variables"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Load this action from HEAD
|
||||
uses: ./
|
||||
|
||||
- name: Partial variables
|
||||
run: |
|
||||
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART }}"
|
||||
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART }}"
|
||||
shell: bash
|
||||
|
||||
- name: Slug variables
|
||||
run: |
|
||||
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
|
||||
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}"
|
||||
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}"
|
||||
echo "ref : ${{ env.GITHUB_REF_SLUG }}"
|
||||
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG }}"
|
||||
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
|
||||
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
|
||||
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
|
||||
shell: bash
|
||||
|
||||
- name: Slug variables (Case Sensitive)
|
||||
run: |
|
||||
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_CS }}"
|
||||
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}"
|
||||
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}"
|
||||
echo "ref : ${{ env.GITHUB_REF_SLUG_CS }}"
|
||||
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_CS }}"
|
||||
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_CS }}"
|
||||
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_CS }}"
|
||||
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_CS }}"
|
||||
shell: bash
|
||||
|
||||
- name: Slug URL variables
|
||||
run: |
|
||||
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
||||
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}"
|
||||
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}"
|
||||
echo "ref : ${{ env.GITHUB_REF_SLUG_URL }}"
|
||||
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_URL }}"
|
||||
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
|
||||
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
|
||||
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
|
||||
shell: bash
|
||||
|
||||
- name: Slug URL variables (Case Sensitive)
|
||||
run: |
|
||||
echo "repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL_CS }}"
|
||||
echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}"
|
||||
echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}"
|
||||
echo "ref : ${{ env.GITHUB_REF_SLUG_URL_CS }}"
|
||||
echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_URL_CS }}"
|
||||
echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL_CS }}"
|
||||
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}"
|
||||
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}"
|
||||
shell: bash
|
||||
|
||||
- name: Ref Point
|
||||
run: |
|
||||
echo "raw : ${{ env.GITHUB_REF_POINT }}"
|
||||
echo "slug : ${{ env.GITHUB_REF_POINT_SLUG }}"
|
||||
echo "slug url : ${{ env.GITHUB_REF_POINT_SLUG_URL }}"
|
||||
echo "slug (Case Sensitive) : ${{ env.GITHUB_REF_POINT_SLUG_CS }}"
|
||||
echo "slug url (Case Sensitive) : ${{ env.GITHUB_REF_POINT_SLUG_URL_CS }}"
|
||||
shell: bash
|
||||
|
||||
- name: Short SHA variables
|
||||
run: |
|
||||
echo "sha : ${{ env.GITHUB_SHA_SHORT }}"
|
||||
echo "pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
|
||||
shell: bash
|
||||
|
||||
display-without-checkout:
|
||||
name: "Display produced variables (without checkout)"
|
||||
needs:
|
||||
- display
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
path: this-action
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
- name: Load this action from HEAD
|
||||
uses: ./this-action
|
||||
|
||||
- name: Short SHA variables
|
||||
run: |
|
||||
echo "sha : ${{ env.GITHUB_SHA_SHORT }}"
|
||||
echo "pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
|
||||
shell: bash
|
||||
|
||||
input-short-length:
|
||||
name: "Input 'short-length'"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
# Test 1
|
||||
- name: Using correct short length
|
||||
uses: ./
|
||||
with:
|
||||
prefix: "CSL_"
|
||||
short-length: 4
|
||||
- name: Using correct length // Validate that all short variables lengths are equals to short-length
|
||||
run: |
|
||||
env | grep "CSL_" | grep "_SHORT" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 5 ] ; done
|
||||
shell: bash
|
||||
|
||||
# Test 2
|
||||
- name: Using wrong short length
|
||||
id: using-wrong-short-length
|
||||
uses: ./
|
||||
with:
|
||||
prefix: "WSL_"
|
||||
short-length: "wrong"
|
||||
continue-on-error: true
|
||||
- name: Using wrong short length // Validate that the action end with an error
|
||||
run: |
|
||||
[[ "$(env | grep "WSL_" | grep "_SHORT" -c)" -eq 0 ]]
|
||||
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
|
||||
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
|
||||
shell: bash
|
||||
|
||||
input-short-length-without-checkout:
|
||||
name: "Input 'short-length' (without checkout)"
|
||||
needs:
|
||||
- input-short-length
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
path: this-action
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
# Test 1
|
||||
- name: Using correct short length
|
||||
uses: ./this-action
|
||||
with:
|
||||
prefix: "CSL_"
|
||||
short-length: 4
|
||||
- name: Using correct length // Validate that all short variables lengths are equals to short-length
|
||||
run: |
|
||||
env | grep "CSL_" | grep "_SHORT" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 5 ] ; done
|
||||
shell: bash
|
||||
|
||||
# Test 2
|
||||
- name: Using empty short length
|
||||
id: using-empty-short-length
|
||||
uses: ./this-action
|
||||
with:
|
||||
prefix: "ESL_"
|
||||
continue-on-error: true
|
||||
- name: Using empty short length // Validate that the action don't end with an error
|
||||
run: |
|
||||
[[ "$(env | grep "ESL_" | grep "_SHORT" -c)" -gt 0 ]]
|
||||
[[ "${{ steps.using-empty-short-length.outcome }}" == "success" ]]
|
||||
[[ "${{ steps.using-empty-short-length.conclusion }}" == "success" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 3
|
||||
- name: Using wrong short length
|
||||
id: using-wrong-short-length
|
||||
uses: ./this-action
|
||||
with:
|
||||
prefix: "WSL_"
|
||||
short-length: "wrong"
|
||||
continue-on-error: true
|
||||
- name: Using wrong short length // Validate that the action end with an error
|
||||
run: |
|
||||
[[ "$(env | grep "WSL_" | grep "_SHORT" -c)" -eq 0 ]]
|
||||
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
|
||||
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
|
||||
shell: bash
|
||||
|
||||
input-slug-maxlength:
|
||||
name: "Input 'slug-maxlength'"
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
|
||||
# Test 1
|
||||
- name: Using correct slug max length
|
||||
uses: ./
|
||||
with:
|
||||
prefix: "CML_"
|
||||
slug-maxlength: 1
|
||||
- name: Using correct max length // Validate that all slug variables lengths are equals or under the slug-maxlength
|
||||
run: |
|
||||
env | grep "CML_" | grep "_SLUG" | cut -d"=" -f2 | while read -r value; do [ "${#value}" -le 2 ] ; done
|
||||
shell: bash
|
||||
|
||||
# Test 2
|
||||
- name: Using wrong slug max length
|
||||
id: using-wrong-slug-max-length
|
||||
uses: ./
|
||||
with:
|
||||
prefix: "WML_"
|
||||
slug-maxlength: "wrong"
|
||||
continue-on-error: true
|
||||
- name: Using wrong slug max length // Validate that the action end with an error
|
||||
run: |
|
||||
[[ "$(env | grep "WML_" | grep "_SLUG" -c)" -eq 0 ]]
|
||||
[[ "${{ steps.using-wrong-slug-max-length.outcome }}" == "failure" ]]
|
||||
[[ "${{ steps.using-wrong-slug-max-length.conclusion }}" == "success" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 3
|
||||
- name: Using empty slug max length
|
||||
id: using-empty-slug-max-length
|
||||
uses: ./
|
||||
with:
|
||||
prefix: "EML_"
|
||||
slug-maxlength: ""
|
||||
continue-on-error: true
|
||||
- name: Using empty slug max length // Validate that the action end with an error
|
||||
run: |
|
||||
[[ "$(env | grep "EML_" | grep "_SLUG" -c)" -eq 0 ]]
|
||||
[[ "${{ steps.using-empty-slug-max-length.outcome }}" == "failure" ]]
|
||||
[[ "${{ steps.using-empty-slug-max-length.conclusion }}" == "success" ]]
|
||||
shell: bash
|
||||
|
||||
# Test 4
|
||||
- name: Using no limit on slug max length
|
||||
id: using-nolimit-slug-max-length
|
||||
uses: ./
|
||||
with:
|
||||
prefix: "NLML_"
|
||||
slug-maxlength: "nolimit"
|
||||
- name: Using no limit on slug max length // Validate that the action end with an error
|
||||
run: |
|
||||
[[ "$(env | grep "NLML_" | grep "_SLUG" -c)" -gt 0 ]]
|
||||
[[ "${{ steps.using-nolimit-slug-max-length.outcome }}" == "success" ]]
|
||||
[[ "${{ steps.using-nolimit-slug-max-length.conclusion }}" == "success" ]]
|
||||
shell: bash
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
id-token: write
|
||||
packages: write
|
||||
concurrency:
|
||||
group: release-${{ github.ref }}-${{ github.event_name }}
|
||||
needs:
|
||||
- display-without-checkout
|
||||
- input-short-length-without-checkout
|
||||
- input-slug-maxlength
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
- name: Release this GitHub Action
|
||||
uses: rlespinasse/release-that@v1
|
||||
with:
|
||||
github-token: ${{ secrets.GH_TOKEN }}
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +0,0 @@
|
||||
node_modules/
|
||||
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,13 +0,0 @@
|
||||
## [2.1.1](http://github.com/rlespinasse/github-slug-action/compare/2.1.0...2.1.1) (2020-10-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* remove set-env due to CVE fix ([d678898](http://github.com/rlespinasse/github-slug-action/commit/d678898ce55139d0005c35618747506fbeb2d1ed))
|
||||
|
||||
# [2.1.0](http://github.com/rlespinasse/github-slug-action/compare/2.0.0...2.1.0) (2020-07-28)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* expose slug variables for github.event.ref ([5a334a8](http://github.com/rlespinasse/github-slug-action/commit/5a334a8573fc27451af5b2a6ee175d8e11579e10))
|
||||
@@ -1,76 +1,133 @@
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, caste, color, religion, or sexual
|
||||
identity and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* The use of sexualized language or imagery, and sexual attention or advances of
|
||||
any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, 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
|
||||
further defined and clarified by project maintainers.
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official email address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at romain.lespinasse@gmail.com. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
reported to the community leaders responsible for enforcement at
|
||||
<romain.lespinasse@gmail.com>.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## 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
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
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
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
||||
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
|
||||
33
CONTRIBUTING.md
Normal file
33
CONTRIBUTING.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# How to contribute to GitHub Slug Action
|
||||
|
||||
## Did you find a bug
|
||||
|
||||
* **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead to refer to our [security policy][1].
|
||||
|
||||
* **Ensure the bug was not already reported** by searching on GitHub under [Issues][2].
|
||||
|
||||
* If you're unable to find an open issue addressing the problem, [open a 'Bug' issue][4].
|
||||
Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
|
||||
|
||||
## Did you write a patch that fixes a bug
|
||||
|
||||
* Open a new GitHub pull request with the patch.
|
||||
|
||||
* Ensure the PR description clearly describes the problem and solution.
|
||||
Include the relevant issue number if applicable.
|
||||
|
||||
## Do you intend to add a new feature or change an existing one
|
||||
|
||||
* Suggest your change by [opening a 'Feature request' issue][5]
|
||||
|
||||
## Do you have questions about the source code
|
||||
|
||||
* [open an issue][3] with your question.
|
||||
|
||||
Thanks!
|
||||
|
||||
[1]: https://github.com/rlespinasse/github-slug-action/security/policy
|
||||
[2]: https://github.com/rlespinasse/github-slug-action/issues
|
||||
[3]: https://github.com/rlespinasse/github-slug-action/issues/new
|
||||
[4]: https://github.com/rlespinasse/github-slug-action/issues/new?assignees=&labels=bug&template=bug_report.md&title=
|
||||
[5]: https://github.com/rlespinasse/github-slug-action/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=
|
||||
@@ -1,4 +0,0 @@
|
||||
FROM alpine:3.10
|
||||
RUN apk add --no-cache jq
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
365
README.md
365
README.md
@@ -1,153 +1,284 @@
|
||||
# GitHub Slug action
|
||||
|
||||
[![Actions Status][1]][2]
|
||||
[![Public workflows that use this action.][8]][9]
|
||||
This GitHub Action will expose the slug/short values of [some GitHub environment variables][default-environment-variables] inside your GitHub workflow.
|
||||
|
||||
This action slug and expose some github variables.
|
||||
## Overview
|
||||
|
||||
`Slug` a variable will
|
||||
`SLUG` on a variable will
|
||||
|
||||
- put the variable content in lower case
|
||||
- replace any character by `-` except `0-9`, `a-z`, and `.`
|
||||
- remove leading and trailing `-` character
|
||||
- replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
||||
- remove leading `-` characters
|
||||
- limit the string size to 63 characters
|
||||
- remove trailing `-` characters
|
||||
|
||||
Others `Slug`-ish commands are available:
|
||||
### Others Slug-ish variables are available
|
||||
|
||||
- `Slug URL` a variable will be like the `slug` variable but the `.` character will also be replaced by `-`
|
||||
- `Short SHA` a variable will limit the string size to 8 characters
|
||||
- `SLUG_URL` on a variable to have a `slug` variable compliant to be used in a URL
|
||||
- Like `SLUG` but `.`, and `_` are also replaced by `-`
|
||||
- `SHORT` on a variable will limit the string size to [~8 characters](#with-another-length-for-short-values)
|
||||
- Useful for _sha_ value
|
||||
- `<KEY>_PART` on a variable will give a part of a variable defined by a key
|
||||
- Like `GITHUB_REPOSITORY_OWNER_PART` for the owner part of `GITHUB_REPOSITORY`
|
||||
- `<VAR>_CS` on other variables to keep the value case-sensitive
|
||||
- Like `GITHUB_REF_SLUG_CS`
|
||||
|
||||
## Exposed environment variables
|
||||
## Installation
|
||||
|
||||
Add this step to your workflow
|
||||
|
||||
```yaml
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v2.x
|
||||
|
||||
- name: Print slug/short variables
|
||||
run: |
|
||||
echo "Slug variables"
|
||||
echo " ref : ${{ env.GITHUB_REF_SLUG }}"
|
||||
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
|
||||
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
|
||||
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
|
||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
|
||||
echo "Slug URL variables"
|
||||
echo " ref : ${{ env.GITHUB_REF_SLUG_URL }}"
|
||||
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
|
||||
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
|
||||
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
|
||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
||||
echo "Short SHA variables"
|
||||
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
||||
steps:
|
||||
- name: Inject enhanced GitHub environment variables
|
||||
uses: rlespinasse/github-slug-action@v5
|
||||
```
|
||||
|
||||
Read [default environment variables][3] page for more information.
|
||||
> [!CAUTION]
|
||||
> Use [Dependabot][dependabot] to maintain your `github-slug-action` version updated in your GitHub workflows.
|
||||
|
||||
### GITHUB_REF_SLUG / GITHUB_REF_SLUG_URL
|
||||
## Configuration Options
|
||||
|
||||
Slug the environment variable **GITHUB_REF**
|
||||
> [!TIP]
|
||||
> Check for more [examples][examples] (OS usage, URL use, ...)
|
||||
|
||||
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 | GITHUB_REF_SLUG_URL |
|
||||
| ------------------------------ | ------------------- | ------------------- |
|
||||
| refs/heads/master | master | master |
|
||||
| refs/heads/feat/new_feature | feat-new-feature | feat-new-feature |
|
||||
| refs/tags/v1.0.0 | v1.0.0 | v1-0-0 |
|
||||
| refs/tags/product@1.0.0-rc.2 | product-1.0.0-rc.2 | product-1-0-0-rc-2 |
|
||||
| refs/heads/New_Awesome_Product | new-awesome-product | new-awesome-product |
|
||||
|
||||
> **NOTE :**
|
||||
> GITHUB_REF_SLUG_URL is design to be used as subdomain in an URL.
|
||||
|
||||
_Additional variables (only set for forked repositories) :_
|
||||
|
||||
- `GITHUB_HEAD_REF_SLUG`/`GITHUB_HEAD_REF_SLUG_URL`, The branch of the head repository **GITHUB_HEAD_REF**
|
||||
- `GITHUB_BASE_REF_SLUG`/`GITHUB_BASE_REF_SLUG_URL`, The branch of the base repository **GITHUB_BASE_REF**
|
||||
|
||||
_Additional variables (only set for [create][4], and [delete][5] webhook events with `ref` data) :_
|
||||
|
||||
- `GITHUB_EVENT_REF_SLUG`/`GITHUB_EVENT_REF_SLUG_URL`, The git reference resource associated to the webhook.
|
||||
|
||||
### GITHUB_REPOSITORY_SLUG / GITHUB_REPOSITORY_SLUG_URL
|
||||
|
||||
Slug the environment variable **GITHUB_REPOSITORY**
|
||||
|
||||
The owner and repository name.
|
||||
|
||||
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG | GITHUB_REPOSITORY_SLUG_URL |
|
||||
| -------------------------- | -------------------------- | -------------------------- |
|
||||
| octocat/Hello-World | octocat-hello-world | octocat-hello-world |
|
||||
| rlespinasse/Hello-World.go | rlespinasse-hello-world.go | rlespinasse-hello-world-go |
|
||||
|
||||
> **NOTE :**
|
||||
> GITHUB_REPOSITORY_SLUG_URL is design to be used as subdomain in an URL.
|
||||
|
||||
### GITHUB_SHA_SHORT
|
||||
|
||||
Short the environment variable **GITHUB_SHA**
|
||||
|
||||
The commit SHA that triggered the workflow
|
||||
|
||||
| GITHUB_SHA | GITHUB_SHA_SHORT |
|
||||
| ---------------------------------------- | ---------------- |
|
||||
| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |
|
||||
|
||||
### Use slug variable in an URL
|
||||
|
||||
In an URL, use `<GITHUB_VARIABLE>_SLUG_URL` instead of **<GITHUB_VARIABLE>\_SLUG** as subdomain to be compliant.
|
||||
|
||||
> **NOTE :**
|
||||
> <GITHUB*VARIABLE>\_SLUG can be used in an URL only as part of the \_resource path*.
|
||||
### With a prefix
|
||||
|
||||
```yaml
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v2.x
|
||||
steps:
|
||||
- name: Inject enhanced GitHub environment variables
|
||||
uses: rlespinasse/github-slug-action@v5
|
||||
with:
|
||||
prefix: CI_
|
||||
```
|
||||
|
||||
- name: Deploy dummy application using slug in the 'subdomain' part
|
||||
run: |
|
||||
./deploy-application.sh --url "https://${{ env.<GITHUB_VARIABLE>_SLUG_URL }}.staging.app.mycompagny.com"
|
||||
### With another max length for slug values
|
||||
|
||||
- name: Deploy dummy application using slug in the 'resource path' part
|
||||
run: |
|
||||
./deploy-application.sh --url "https://staging.app.mycompagny.com/${{ env.<GITHUB_VARIABLE>_SLUG }}"
|
||||
```yaml
|
||||
steps:
|
||||
- name: Inject enhanced GitHub environment variables
|
||||
uses: rlespinasse/github-slug-action@v5
|
||||
with:
|
||||
slug-maxlength: 80 # Use 'nolimit' to remove use of a max length (Default to 63)
|
||||
```
|
||||
|
||||
### With another length for short values
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- name: Inject enhanced GitHub environment variables
|
||||
uses: rlespinasse/github-slug-action@v5
|
||||
with:
|
||||
short-length: 7 # By default it's up to Git to decide, use 8 to have the v3.x behaviour
|
||||
```
|
||||
|
||||
The length of a short sha depends on the size of **your repository** and can differ over time :
|
||||
|
||||
- set `7` to keep the `small repository` behaviour,
|
||||
- set `8` to reproduce `v3` behaviour,
|
||||
- set `4` as the minimum length possible.
|
||||
|
||||
> [!WARNING]
|
||||
> If you leave it empty, you need to checkout the source first to let Git decide the size by itself by using [`git rev-parse`][git-revparse] behaviour.
|
||||
>
|
||||
> The default is the effective value of the [core.abbrev][git-core-abbrev] configuration variable.
|
||||
|
||||
## Available Environment variables
|
||||
|
||||
> [!TIP]
|
||||
> If you don't find what you search for
|
||||
>
|
||||
> - Read more about [available `GitHub` variables](docs/github-variables.md), and propose a [new custom variable][custom-variable].
|
||||
> - Use your own variable with [slugify-value][slugify-value], or [shortify-git-revision][shortify-git-revision] for git reference.
|
||||
|
||||
### Enhanced variables
|
||||
|
||||
- `GITHUB_REF_POINT` will contain the reference name (branch or tag)
|
||||
- based on `GITHUB_HEAD_REF` in a [`pull-request*`][webhooks-and-events] event context,
|
||||
- based on `GITHUB_REF_NAME` in other event context.
|
||||
|
||||
> [!NOTE]
|
||||
> All enhanced variables are available in all **slug** formats.
|
||||
|
||||
### Partial variables
|
||||
|
||||
| Variable | Description |
|
||||
| -------- | ----------- |
|
||||
| [GITHUB_REPOSITORY_OWNER_PART](docs/partial-variables.md#github_repository_owner_part) | The Owner part of GITHUB_REPOSITORY variable |
|
||||
| [GITHUB_REPOSITORY_NAME_PART](docs/partial-variables.md#github_repository_name_part) | The Repository name part of GITHUB_REPOSITORY variable |
|
||||
|
||||
### Slug variables
|
||||
|
||||
> [!TIP]
|
||||
> Available in standard and case-sensitive (`_CS`) versions.
|
||||
|
||||
| Variable | Description |
|
||||
| -------- | ----------- |
|
||||
| [GITHUB_REPOSITORY_SLUG](docs/slug-variables.md#github_repository_slug) | The owner and repository name. |
|
||||
| [GITHUB_REPOSITORY_OWNER_PART_SLUG](docs/slug-variables.md#github_repository_owner_part_slug) | The owner name. |
|
||||
| [GITHUB_REPOSITORY_NAME_PART_SLUG](docs/slug-variables.md#github_repository_name_part_slug) | The repository name. |
|
||||
| [GITHUB_REF_SLUG](docs/slug-variables.md#github_ref_slug) | The branch or tag ref that triggered the workflow. |
|
||||
| [GITHUB_REF_NAME_SLUG](docs/slug-variables.md#github_ref_name_slug) | This value matches the branch or tag name shown on GitHub. |
|
||||
| [GITHUB_HEAD_REF_SLUG](docs/slug-variables.md#github_head_ref_slug) | The branch of the head repository. |
|
||||
| [GITHUB_BASE_REF_SLUG](docs/slug-variables.md#github_base_ref_slug) | The branch of the base repository. |
|
||||
| [GITHUB_EVENT_REF_SLUG](docs/slug-variables.md#github_event_ref_slug) | The Git reference resource associated to triggered webhook. |
|
||||
|
||||
### URL-Safe Slug variables
|
||||
|
||||
Same as slug variables but URL-compliant
|
||||
|
||||
> [!TIP]
|
||||
> Available in standard and case-sensitive (`_CS`) versions.
|
||||
|
||||
| Variable | Description |
|
||||
| -------- | ----------- |
|
||||
| [GITHUB_REPOSITORY_SLUG_URL](docs/slug-url-variables.md#github_repository_slug_url) | The owner and repository name. |
|
||||
| [GITHUB_REPOSITORY_OWNER_PART_SLUG_URL](docs/slug-variables.md#github_repository_owner_part_slug_url) | The owner name. |
|
||||
| [GITHUB_REPOSITORY_NAME_PART_SLUG_URL](docs/slug-variables.md#github_repository_name_part_slug_url) | The repository name. |
|
||||
| [GITHUB_REF_SLUG_URL](docs/slug-url-variables.md#github_ref_slug_url) | The branch or tag ref that triggered the workflow. |
|
||||
| [GITHUB_REF_NAME_SLUG_URL](docs/slug-url-variables.md#github_ref_slug_url) | This value matches the branch or tag name shown on GitHub. |
|
||||
| [GITHUB_HEAD_REF_SLUG_URL](docs/slug-url-variables.md#github_head_ref_slug_url) | The branch of the head repository. |
|
||||
| [GITHUB_BASE_REF_SLUG_URL](docs/slug-url-variables.md#github_base_ref_slug_url) | The branch of the base repository. |
|
||||
| [GITHUB_EVENT_REF_SLUG_URL](docs/slug-url-variables.md#github_event_ref_slug_url) | The Git reference resource associated to triggered webhook. |
|
||||
|
||||
### Short variables
|
||||
|
||||
| Variable | Description |
|
||||
| -------- | ----------- |
|
||||
| [GITHUB_SHA_SHORT](docs/short-variables.md#github_sha_short) | The commit SHA that triggered the workflow. |
|
||||
| [GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT](docs/short-variables.md#github_event_pull_request_head_sha_short) | The commit SHA on pull request that trigger workflow. |
|
||||
|
||||
## Migration from previous versions
|
||||
|
||||
### v4 to v5
|
||||
|
||||
The **GITHUB_REF_NAME SLUG/SLUG_URL** variables don't work the same way as before
|
||||
|
||||
> [!TIP]
|
||||
> If you use `v5` or related versions, you need to use `GITHUB_REF_POINT` instead of `GITHUB_REF_NAME` to get the behaviour of the `v4` action.
|
||||
|
||||
Before `v5`, the behaviour was the same as the GitHub one except on `pull_request*` workflows ([Ready the full story][issue-104]).
|
||||
|
||||
- `${{ env.GITHUB_REF_NAME }}` will serve the behaviour of this action,
|
||||
- `$GITHUB_REF_NAME` will serve the behaviour of GitHub Action.
|
||||
|
||||
On `pull_request*` workflows, the content will be `<PR-number>/merge` instead of the branch name.
|
||||
So you need to use `GITHUB_REF_POINT` instead
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- name: Inject enhanced GitHub environment variables
|
||||
uses: rlespinasse/github-slug-action@v5
|
||||
- run: |
|
||||
echo "Branch Name: ${GITHUB_REF_POINT}"
|
||||
shell: bash
|
||||
|
||||
```
|
||||
|
||||
Then `${{ env.GITHUB_REF_POINT }}`, and `$GITHUB_REF_POINT` will serve the behaviour of this action.
|
||||
And `${{ env.GITHUB_REF_NAME }}`, and `$GITHUB_REF_NAME` will serve the behaviour of GitHub Action.
|
||||
|
||||
### v3 to v4
|
||||
|
||||
Since `v4`, 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 differ over time.
|
||||
|
||||
To manage that moving length, you can use the `short-length` input
|
||||
|
||||
- set `7` to reproduce `small repository` behaviour
|
||||
- set `8` to reproduce `v3` behaviour
|
||||
|
||||
> [!WARNING]
|
||||
> The minimum length is 4, the default is the effective value of the [core.abbrev][git-core-abbrev] configuration variable.
|
||||
|
||||
So to reproduce previous behaviour, use
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- name: Inject enhanced GitHub environment variables
|
||||
uses: rlespinasse/github-slug-action@v5
|
||||
with:
|
||||
short-length: 8 # Same as v3 and before
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Missing master branch
|
||||
### One of the environment variables doesn't work as intended
|
||||
|
||||
If your workflow fail on the `Set up job` task with this kind of log :
|
||||
> [!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.**
|
||||
|
||||
```
|
||||
Download action repository 'rlespinasse/github-slug-action@master'
|
||||
##[error]An action could not be found at the URI 'https://api.github.com/repos/rlespinasse/github-slug-action/tarball/master'
|
||||
If a variable starts to be used as a default environment variable, the environment variable may behave differently 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 behaviour of this action,
|
||||
- `$GITHUB_AWESOME_VARIABLE` will serve the behaviour of GitHub Action.
|
||||
|
||||
Otherwise, the two expressions will serve the behaviour of this action.
|
||||
This will not occur if you use the `prefix` input to avoid the issue.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> If detected, the maintainers of this action will choose the best course of action depending 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'
|
||||
```
|
||||
|
||||
Use the current branch `v2.x` or a version tag (see [releases pages][6]).
|
||||
If the `GIT_REFERENCE` value is
|
||||
|
||||
The master branch EOL is set on **2020-10-25** after a 6-month deprecation period (more information on the [EOL issue][7])
|
||||
- `v4.x` or after, following the [end-of-life for a branch](SECURITY.md#end-of-life-of-a-branch) security process, this branch can be deleted.
|
||||
- `master`, the branch doesn't exist anymore, read more about it on the corresponding issue ([EOL issue][issue-15])
|
||||
|
||||
### Can't run on Windows or Macos
|
||||
Please, use the current **Major tag** `v5` or a version tag (see [releases pages][releases]) to fix your workflow.
|
||||
|
||||
When using this action on Windows or Macos workflows, A `##[error]Container action is only supported on Linux` error can be see in your workflow logs.
|
||||
Currently, this action don't support a system other than Linux due to Github Action Limitation on `Container`-based action.
|
||||
## Thanks for talking about us
|
||||
|
||||
On the `v3.x` branch, this GitHub action have been rewrite to be able to run on Windows or Macos workflow.
|
||||
In English :gb:
|
||||
|
||||
```yaml
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v3.x
|
||||
```
|
||||
- [Action spotlight by Michael Heap][article-2]
|
||||
- [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]
|
||||
- [Celebrating 5 Years of github-slug-action on sfeir.dev][article-7]
|
||||
|
||||
[1]: https://github.com/rlespinasse/github-slug-action/workflows/Build/badge.svg
|
||||
[2]: https://github.com/rlespinasse/github-slug-action/actions
|
||||
[3]: https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
||||
[4]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#create
|
||||
[5]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#delete
|
||||
[6]: https://github.com/rlespinasse/github-slug-action/releases
|
||||
[7]: https://github.com/rlespinasse/github-slug-action/issues/15
|
||||
[8]: https://img.shields.io/endpoint?url=https%3A%2F%2Fapi-git-master.endbug.vercel.app%2Fapi%2Fgithub-actions%2Fused-by%3Faction%3Drlespinasse%2Fgithub-slug-action%26badge%3Dtrue
|
||||
[9]: https://github.com/search?o=desc&q=rlespinasse%2Frlespinasse/github-slug-action+path%3A.github%2Fworkflows+language%3AYAML&s=&type=Code
|
||||
In French :fr:
|
||||
|
||||
- [Mettre en place une CI/CD Angular avec GitHub Actions & Netlify][article-1]
|
||||
- [GitHub Actions : enfin des pipelines accessibles aux développeurs][talk-1]
|
||||
- [GitHub-slug-action : 5 ans d'open source pour cette GitHub Action essentielle au CI/CD][article-6]
|
||||
|
||||
In Chinese :cn:
|
||||
|
||||
- [利用github-slug-action暴漏GitHub Action上下文中的关键变量][article-5]
|
||||
|
||||
> The next one is you. _Don't hesitate to add yourself to one of these lists._
|
||||
|
||||
[examples]: https://github.com/rlespinasse/github-slug-action/tree/v5.x/examples
|
||||
[custom-variable]: https://github.com/rlespinasse/github-slug-action/issues/new?assignees=&labels=enhancement&template=feature_request.md&title=
|
||||
[releases]: https://github.com/rlespinasse/github-slug-action/releases
|
||||
[issue-15]: https://github.com/rlespinasse/github-slug-action/issues/15
|
||||
[issue-104]: https://github.com/rlespinasse/github-slug-action/issues/104
|
||||
|
||||
[slugify-value]: https://github.com/rlespinasse/slugify-value
|
||||
[shortify-git-revision]: https://github.com/rlespinasse/shortify-git-revision
|
||||
|
||||
[git-revparse]: https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---shortlength
|
||||
[git-core-abbrev]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreabbrev
|
||||
|
||||
[default-environment-variables]: https://docs.github.com/en/actions/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
|
||||
[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/workflows-and-actions/variables#naming-conventions-for-configuration-variables
|
||||
|
||||
[article-1]: https://esensconsulting.medium.com/mettre-en-place-une-ci-cd-angular-avec-github-actions-netlify-ca0b59b99ed8
|
||||
[article-2]: https://michaelheap.com/github-slug-action/
|
||||
[article-3]: https://barstool.engineering/serverless-deploy-previews-on-github-actions/
|
||||
[article-4]: https://javascript.plainenglish.io/lets-build-a-continuous-delivery-and-branching-process-c27dae09f0b6
|
||||
[article-5]: https://eryajf.github.io/HowToStartOpenSource/views/03-github-tips/10-Use-github-slug-action-to-leak-key-variables-in-the-Github-Action-context.html
|
||||
[article-6]: https://www.sfeir.dev/5-ans-de-github-slug-action-une-aventure-open-source/
|
||||
[article-7]: https://www.romainlespinasse.dev/posts/celebrating-5-years-of-github-slug-action/
|
||||
[talk-1]: https://www.youtube.com/watch?v=F5mBDmOQcvE
|
||||
|
||||
32
SECURITY.md
32
SECURITY.md
@@ -2,22 +2,26 @@
|
||||
|
||||
## Supported Versions and Branches
|
||||
|
||||
| Version | Branch | Supported |
|
||||
|---------|--------|--------------------|
|
||||
| 2.x | v2.x | :white_check_mark: |
|
||||
| 1.1.x | v1.1.x | :white_check_mark: |
|
||||
| < 1.0.x | master | :x: |
|
||||
| Version | Supported | End of Support | Branch | Specific Tags |
|
||||
| ------- | ------------------ | -------------- | ------ | ------------- |
|
||||
| 5.x | :white_check_mark: | | v5.x | v5 |
|
||||
| 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 |
|
||||
| 1.x | :x: | 2021-04-05 | | v1.1.x, 1.2.0 |
|
||||
| 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
|
||||
|
||||
Since `2023-10-20`, when a new major version is released,
|
||||
|
||||
- The previous one will continue to receive security patches for 3 months,
|
||||
- After the 3 months, the branch is deleted, and only the tags remain.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
You can report a Vulnerability by [my email](mailto:romain.lespinasse@gmail.com).
|
||||
In this project, you can report a Vulnerability by creating a [draft security advisory](https://github.com/rlespinasse/github-slug-action/security/advisories).
|
||||
|
||||
_Vulnerability stages :_
|
||||
|
||||
- Reported,
|
||||
- Confirmed (or declined),
|
||||
- Fixed on maintained version series.
|
||||
|
||||
After a vulnerability fix, an GitHub issue will be created as document this vulnerability.
|
||||
If the vulnerability is confirmed, a fix will be produced and the advisory will be published.
|
||||
|
||||
127
action.yml
127
action.yml
@@ -1,9 +1,120 @@
|
||||
# action.yml
|
||||
name: "GitHub Slug"
|
||||
description: "Action to slug and expose some github variables"
|
||||
runs:
|
||||
using: "docker"
|
||||
image: "Dockerfile"
|
||||
name: "GitHub Slug Action"
|
||||
description: "GitHub Action to expose slug value of environment variables inside your GitHub workflow"
|
||||
author: "Romain Lespinasse"
|
||||
branding:
|
||||
icon: "crop"
|
||||
color: "orange"
|
||||
icon: "minimize"
|
||||
color: "blue"
|
||||
inputs:
|
||||
prefix:
|
||||
description: "Value to prepend to each generated variable"
|
||||
default: ""
|
||||
required: false
|
||||
slug-maxlength:
|
||||
description: "Max length of the slugified values"
|
||||
default: "63"
|
||||
required: true
|
||||
short-length:
|
||||
description: "Length of the shortify values (git default if empty)"
|
||||
required: false
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- run: $GITHUB_ACTION_PATH/preflight.sh
|
||||
id: prefligth
|
||||
shell: bash
|
||||
env:
|
||||
INPUT_SLUG_MAXLENGTH: ${{ inputs.slug-maxlength }}
|
||||
INPUT_SHORT_LENGTH: ${{ inputs.short-length }}
|
||||
|
||||
# From Environment Variables
|
||||
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||
with:
|
||||
key: GITHUB_REPOSITORY
|
||||
value: ${{ github.repository }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||
with:
|
||||
key: GITHUB_REF
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||
with:
|
||||
key: GITHUB_HEAD_REF
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||
with:
|
||||
key: GITHUB_BASE_REF
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
|
||||
# From Specific values
|
||||
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||
with:
|
||||
key: GITHUB_EVENT_REF
|
||||
value: ${{ github.event.ref }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||
with:
|
||||
key: GITHUB_REF_NAME
|
||||
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 }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
env:
|
||||
GITHUB_HEAD_REF_RAW: ${{ github.head_ref }}
|
||||
GITHUB_REF_NAME_RAW: ${{ github.ref_name }}
|
||||
|
||||
# From Calculated values
|
||||
- id: get-github-repository-owner-part
|
||||
run: |
|
||||
ownerpart=$(echo $GITHUB_REPOSITORY | cut -d/ -f1)
|
||||
if [ -f "$GITHUB_OUTPUT" ]; then
|
||||
echo "github-repository-owner-part=${ownerpart}" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "::set-output name=github-repository-owner-part::${ownerpart}"
|
||||
fi
|
||||
shell: bash
|
||||
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||
with:
|
||||
key: GITHUB_REPOSITORY_OWNER_PART
|
||||
value: ${{ steps.get-github-repository-owner-part.outputs.github-repository-owner-part }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- id: get-github-repository-name-part
|
||||
run: |
|
||||
namepart=$(echo $GITHUB_REPOSITORY | cut -d/ -f2)
|
||||
if [ -f "$GITHUB_OUTPUT" ]; then
|
||||
echo "github-repository-name-part=${namepart}" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "::set-output name=github-repository-name-part::${namepart}"
|
||||
fi
|
||||
shell: bash
|
||||
- uses: rlespinasse/slugify-value@a4879db1eb3db9bbee01dca36f98a8236c2b8239 # v1.4.0
|
||||
with:
|
||||
key: GITHUB_REPOSITORY_NAME_PART
|
||||
value: ${{ steps.get-github-repository-name-part.outputs.github-repository-name-part }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
|
||||
# From sha
|
||||
- uses: rlespinasse/shortify-git-revision@c90ba7007ef6c152254d10b9f1a327966ab13077 # v1.6.0
|
||||
with:
|
||||
name: GITHUB_SHA
|
||||
short-on-error: true
|
||||
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
- uses: rlespinasse/shortify-git-revision@c90ba7007ef6c152254d10b9f1a327966ab13077 # v1.6.0
|
||||
with:
|
||||
name: GITHUB_EVENT_PULL_REQUEST_HEAD_SHA
|
||||
revision: ${{ github.event.pull_request.head.sha }}
|
||||
short-on-error: true
|
||||
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
|
||||
97
docs/github-variables.md
Normal file
97
docs/github-variables.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# Available GitHub Variables
|
||||
|
||||
All `GitHub` variables availables in your workflow in addition of ones exposed by this Action
|
||||
|
||||
## 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_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 |
|
||||
|
||||
[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
|
||||
28
docs/partial-variables.md
Normal file
28
docs/partial-variables.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Partial Variables
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [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 |
|
||||
27
docs/short-variables.md
Normal file
27
docs/short-variables.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# Short Variables
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [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 |
|
||||
123
docs/slug-url-variables.md
Normal file
123
docs/slug-url-variables.md
Normal file
@@ -0,0 +1,123 @@
|
||||
# Slug URL Variables
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [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\_REF\_NAME\_SLUG\_URL](#github_ref_name_slug_url)
|
||||
- [GITHUB\_HEAD\_REF\_SLUG\_URL](#github_head_ref_slug_url)
|
||||
- [GITHUB\_BASE\_REF\_SLUG\_URL](#github_base_ref_slug_url)
|
||||
- [GITHUB\_EVENT\_REF\_SLUG\_URL](#github_event_ref_slug_url)
|
||||
|
||||
## GITHUB_REPOSITORY_SLUG_URL
|
||||
|
||||
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 |
|
||||
|
||||
## GITHUB_REF_NAME_SLUG_URL
|
||||
|
||||
Slug URL the environment variable **GITHUB_REF_NAME**
|
||||
|
||||
The branch or tag ref that triggered the workflow.
|
||||
_If neither a branch or tag is available for the event type, the variable will not exist._
|
||||
|
||||
| GITHUB_REF_NAME | GITHUB_REF_SLUG_URL |
|
||||
| --------------- | ------------------- |
|
||||
| refs/heads/main | main |
|
||||
| refs/heads/feat/new_feature | feat-new-feature |
|
||||
| refs/tags/v1.0.0 | v1-0-0 |
|
||||
| refs/pull/42/merge | 42-merge |
|
||||
| refs/tags/product@1.0.0-rc.2 | product-1-0-0-rc-2 |
|
||||
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||
|
||||
## GITHUB_HEAD_REF_SLUG_URL
|
||||
|
||||
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
|
||||
122
docs/slug-variables.md
Normal file
122
docs/slug-variables.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# Slug Variables
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [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\_REF\_NAME\_SLUG](#github_ref_name_slug)
|
||||
- [GITHUB\_HEAD\_REF\_SLUG](#github_head_ref_slug)
|
||||
- [GITHUB\_BASE\_REF\_SLUG](#github_base_ref_slug)
|
||||
- [GITHUB\_EVENT\_REF\_SLUG](#github_event_ref_slug)
|
||||
|
||||
## GITHUB_REPOSITORY_SLUG
|
||||
|
||||
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_REF_NAME_SLUG
|
||||
|
||||
Slug the environment variable **GITHUB_REF_NAME**
|
||||
|
||||
The branch or tag ref that triggered the workflow.
|
||||
_If neither a branch or tag is available for the event type, the variable will not exist._
|
||||
|
||||
| GITHUB_REF_NAME | GITHUB_REF_SLUG |
|
||||
| --------------- | --------------- |
|
||||
| main | main |
|
||||
| feat/new_feature | feat-new-feature |
|
||||
| v1.0.0 | v1.0.0 |
|
||||
| product@1.0.0-rc.2 | product-1.0.0-rc.2 |
|
||||
| New_Awesome_Product | new-awesome-product |
|
||||
| 42/merge | 42-merge |
|
||||
|
||||
## GITHUB_HEAD_REF_SLUG
|
||||
|
||||
Slug the environment variable **GITHUB_HEAD_REF**
|
||||
|
||||
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
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/bin/sh -l
|
||||
|
||||
slug() {
|
||||
echo "$1" |
|
||||
tr "[:upper:]" "[:lower:]" |
|
||||
sed -r 's/[~\^]+//g;s/[^a-zA-Z0-9.]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' |
|
||||
cut -c1-63
|
||||
}
|
||||
|
||||
slug_url() {
|
||||
echo "$1" |
|
||||
tr "[:upper:]" "[:lower:]" |
|
||||
sed -r 's/[~\^]+//g;s/[^a-zA-Z0-9]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' |
|
||||
cut -c1-63
|
||||
}
|
||||
|
||||
slug_ref() {
|
||||
echo "$1" |
|
||||
tr "[:upper:]" "[:lower:]" |
|
||||
sed -r 's#refs/[^\/]*/##;s/[~\^]+//g;s/[^a-zA-Z0-9.]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' |
|
||||
cut -c1-63
|
||||
}
|
||||
|
||||
slug_url_ref() {
|
||||
echo "$1" |
|
||||
tr "[:upper:]" "[:lower:]" |
|
||||
sed -r 's#refs/[^\/]*/##;s/[~\^]+//g;s/[^a-zA-Z0-9]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' |
|
||||
cut -c1-63
|
||||
}
|
||||
|
||||
short_sha() {
|
||||
echo "$1" |
|
||||
cut -c1-8
|
||||
}
|
||||
|
||||
get_event_keyvalue() {
|
||||
if [ -f "$GITHUB_EVENT_PATH" ]; then
|
||||
jq -r ".$1" "$GITHUB_EVENT_PATH" | grep -v "null"
|
||||
fi
|
||||
}
|
||||
|
||||
{
|
||||
echo "GITHUB_REPOSITORY_SLUG=$(slug "$GITHUB_REPOSITORY")"
|
||||
echo "GITHUB_REPOSITORY_SLUG_URL=$(slug_url "$GITHUB_REPOSITORY")"
|
||||
echo "GITHUB_REF_SLUG=$(slug_ref "$GITHUB_REF")"
|
||||
echo "GITHUB_HEAD_REF_SLUG=$(slug_ref "$GITHUB_HEAD_REF")"
|
||||
echo "GITHUB_BASE_REF_SLUG=$(slug_ref "$GITHUB_BASE_REF")"
|
||||
echo "GITHUB_EVENT_REF_SLUG=$(slug_ref "$(get_event_keyvalue "ref")")"
|
||||
echo "GITHUB_REF_SLUG_URL=$(slug_url_ref "$GITHUB_REF")"
|
||||
echo "GITHUB_HEAD_REF_SLUG_URL=$(slug_url_ref "$GITHUB_HEAD_REF")"
|
||||
echo "GITHUB_BASE_REF_SLUG_URL=$(slug_url_ref "$GITHUB_BASE_REF")"
|
||||
echo "GITHUB_EVENT_REF_SLUG_URL=$(slug_url_ref "$(get_event_keyvalue "ref")")"
|
||||
echo "GITHUB_SHA_SHORT=$(short_sha "$GITHUB_SHA")"
|
||||
} >>"$GITHUB_ENV"
|
||||
34
examples/linux-usage.yml
Normal file
34
examples/linux-usage.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
name: Linux usage
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
usage:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: rlespinasse/github-slug-action@v5
|
||||
- name: Output
|
||||
run: |
|
||||
echo "Partial variables"
|
||||
echo " repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART }}"
|
||||
echo " repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART }}"
|
||||
echo "Slug variables"
|
||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
|
||||
echo " repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}"
|
||||
echo " repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}"
|
||||
echo " ref : ${{ env.GITHUB_REF_SLUG }}"
|
||||
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
|
||||
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
|
||||
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
|
||||
echo "Slug URL variables"
|
||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
||||
echo " repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}"
|
||||
echo " repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}"
|
||||
echo " ref : ${{ env.GITHUB_REF_SLUG_URL }}"
|
||||
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
|
||||
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
|
||||
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
|
||||
echo "Short SHA variables"
|
||||
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
||||
echo " pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
|
||||
34
examples/macos-usage.yml
Normal file
34
examples/macos-usage.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
name: MacOS usage
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
usage:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: rlespinasse/github-slug-action@v5
|
||||
- name: Output
|
||||
run: |
|
||||
echo "Partial variables"
|
||||
echo " repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART }}"
|
||||
echo " repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART }}"
|
||||
echo "Slug variables"
|
||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
|
||||
echo " repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}"
|
||||
echo " repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}"
|
||||
echo " ref : ${{ env.GITHUB_REF_SLUG }}"
|
||||
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
|
||||
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
|
||||
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
|
||||
echo "Slug URL variables"
|
||||
echo " repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
|
||||
echo " repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}"
|
||||
echo " repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}"
|
||||
echo " ref : ${{ env.GITHUB_REF_SLUG_URL }}"
|
||||
echo " head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
|
||||
echo " base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
|
||||
echo " event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
|
||||
echo "Short SHA variables"
|
||||
echo " sha : ${{ env.GITHUB_SHA_SHORT }}"
|
||||
echo " pull request sha : ${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
|
||||
20
examples/url-use.yml
Normal file
20
examples/url-use.yml
Normal file
@@ -0,0 +1,20 @@
|
||||
name: URL use
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
as_subdomain:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: rlespinasse/github-slug-action@v5
|
||||
- run: |
|
||||
./deploy-application.sh --url "https://${{ env.GITHUB_REF_SLUG_URL }}.staging.app.example.com"
|
||||
|
||||
as_resource_path:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: rlespinasse/github-slug-action@v5
|
||||
- run: |
|
||||
./deploy-application.sh --url "https://staging.app.example.com/${{ env.GITHUB_REF_SLUG_URL }}"
|
||||
34
examples/windows-usage.yml
Normal file
34
examples/windows-usage.yml
Normal file
@@ -0,0 +1,34 @@
|
||||
name: Windows usage
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
usage:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: rlespinasse/github-slug-action@v5
|
||||
- name: Output
|
||||
run: |
|
||||
echo "Partial variables"
|
||||
echo " repository owner : $env:GITHUB_REPOSITORY_OWNER_PART"
|
||||
echo " repository name : $env:GITHUB_REPOSITORY_NAME_PART"
|
||||
echo "Slug variables"
|
||||
echo " repository : $env:GITHUB_REPOSITORY_SLUG"
|
||||
echo " repository owner : $env:GITHUB_REPOSITORY_OWNER_PART_SLUG"
|
||||
echo " repository name : $env:GITHUB_REPOSITORY_NAME_PART_SLUG"
|
||||
echo " ref : $env:GITHUB_REF_SLUG"
|
||||
echo " head ref : $env:GITHUB_HEAD_REF_SLUG"
|
||||
echo " base ref : $env:GITHUB_BASE_REF_SLUG"
|
||||
echo " event ref : $env:GITHUB_EVENT_REF_SLUG"
|
||||
echo "Slug URL variables"
|
||||
echo " repository : $env:GITHUB_REPOSITORY_SLUG_URL"
|
||||
echo " repository owner : $env:GITHUB_REPOSITORY_OWNER_PART_SLUG_URL"
|
||||
echo " repository name : $env:GITHUB_REPOSITORY_NAME_PART_SLUG_URL"
|
||||
echo " ref : $env:GITHUB_REF_SLUG_URL"
|
||||
echo " head ref : $env:GITHUB_HEAD_REF_SLUG_URL"
|
||||
echo " base ref : $env:GITHUB_BASE_REF_SLUG_URL"
|
||||
echo " event ref : $env:GITHUB_EVENT_REF_SLUG_URL"
|
||||
echo "Short SHA variables"
|
||||
echo " sha : $env:GITHUB_SHA_SHORT"
|
||||
echo " pull request sha : $env:GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT"
|
||||
6156
package-lock.json
generated
6156
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@@ -1,32 +0,0 @@
|
||||
{
|
||||
"name": "github-slug-action",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "docker run -w /workdir -v $(pwd):/workdir ffurrer/bats:latest --recursive .",
|
||||
"release": "semantic-release"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/rlespinasse/github-slug-action.git"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "5.0.1",
|
||||
"@semantic-release/git": "9.0.0",
|
||||
"semantic-release": "17.0.7"
|
||||
},
|
||||
"release": {
|
||||
"tagFormat": "${version}",
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/changelog",
|
||||
"@semantic-release/git",
|
||||
"@semantic-release/github"
|
||||
],
|
||||
"branches": [
|
||||
"v1.1.x",
|
||||
"v2.x"
|
||||
]
|
||||
}
|
||||
}
|
||||
38
preflight.sh
Executable file
38
preflight.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ -z "${INPUT_SLUG_MAXLENGTH}" ]; then
|
||||
echo "::error ::slug-maxlength cannot be empty"
|
||||
exit 1
|
||||
elif [ "${INPUT_SLUG_MAXLENGTH}" != "nolimit" ] && [ ! "${INPUT_SLUG_MAXLENGTH}" -eq "${INPUT_SLUG_MAXLENGTH}" ] 2>/dev/null; then
|
||||
echo "::error ::slug-maxlength must be a number or equals to 'nolimit'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! "${INPUT_SHORT_LENGTH}" -eq "${INPUT_SHORT_LENGTH}" ] 2>/dev/null; then
|
||||
echo "::error ::short-length must be a number"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "::debug ::Control preflight short-length setup"
|
||||
PREFLIGHT_SHORT_LENGTH=""
|
||||
if [ -n "${INPUT_SHORT_LENGTH}" ]; then
|
||||
PREFLIGHT_SHORT_LENGTH="${INPUT_SHORT_LENGTH}"
|
||||
echo "::debug ::Use input value: $PREFLIGHT_SHORT_LENGTH"
|
||||
elif [ "$(git rev-parse --is-inside-work-tree)" == "true" ]; then
|
||||
echo "::debug ::The action run inside a git repository, short-length can be empty"
|
||||
else
|
||||
echo "::debug ::The action run outside a git repository, need to set short-length"
|
||||
PREFLIGHT_SHORT_LENGTH="$(git config --get core.abbrev)"
|
||||
if [ -n "${PREFLIGHT_SHORT_LENGTH}" ]; then
|
||||
echo "::debug ::Git Configuration 'core.abbrev' is set, using it as short-length"
|
||||
else
|
||||
PREFLIGHT_SHORT_LENGTH="7"
|
||||
echo "::debug ::Using fallback value for short-length"
|
||||
fi
|
||||
fi
|
||||
echo "::debug ::Set PREFLIGHT_SHORT_LENGTH=$PREFLIGHT_SHORT_LENGTH"
|
||||
if [ -f "$GITHUB_OUTPUT" ]; then
|
||||
echo "PREFLIGHT_SHORT_LENGTH=${PREFLIGHT_SHORT_LENGTH}" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "::set-output name=PREFLIGHT_SHORT_LENGTH::${PREFLIGHT_SHORT_LENGTH}"
|
||||
fi
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
@test "short_sha: long hash" {
|
||||
test_short_sha \
|
||||
"a35a1a486a260cfd99c5b6f8c6034a2929ba9b3f" \
|
||||
"a35a1a48"
|
||||
}
|
||||
|
||||
# Load sluf_ref function
|
||||
source entrypoint.sh > /dev/null 2>&1
|
||||
|
||||
test_short_sha(){
|
||||
given="${1}"
|
||||
expected="${2}"
|
||||
|
||||
actual="$(short_sha ${given})"
|
||||
echo "expected : [${expected}], actual : [${actual}]"
|
||||
[ "${actual}" == "${expected}" ]
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
@test "slug: a word" {
|
||||
test_slug \
|
||||
"word" \
|
||||
"word"
|
||||
}
|
||||
|
||||
@test "slug: a string" {
|
||||
test_slug \
|
||||
"basic-string" \
|
||||
"basic-string"
|
||||
}
|
||||
|
||||
@test "slug: a string in camel case" {
|
||||
test_slug \
|
||||
"camelCase" \
|
||||
"camelcase"
|
||||
}
|
||||
|
||||
@test "slug: a path" {
|
||||
test_slug \
|
||||
"path/to/something" \
|
||||
"path-to-something"
|
||||
}
|
||||
|
||||
@test "slug: a number" {
|
||||
test_slug \
|
||||
"4.2" \
|
||||
"4.2"
|
||||
}
|
||||
|
||||
@test "slug: a very long string" {
|
||||
test_slug \
|
||||
"an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters" \
|
||||
"an-awesome-feature-very-very-very-very-very-very-very-long-more"
|
||||
}
|
||||
|
||||
# Load sluf_ref function
|
||||
source entrypoint.sh > /dev/null 2>&1
|
||||
|
||||
test_slug() {
|
||||
given="${1}"
|
||||
expected="${2}"
|
||||
|
||||
actual="$(slug \"${given}\")"
|
||||
echo "expected : [${expected}], actual : [${actual}]"
|
||||
[ "${actual}" == "${expected}" ]
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
@test "slug_ref:: master branch" {
|
||||
test_slug_ref \
|
||||
"refs/heads/master" \
|
||||
"master"
|
||||
}
|
||||
|
||||
@test "slug_ref: a feature branch" {
|
||||
test_slug_ref \
|
||||
"refs/heads/feat/new_feature" \
|
||||
"feat-new-feature"
|
||||
}
|
||||
|
||||
@test "slug_ref: a fix branch" {
|
||||
test_slug_ref \
|
||||
"refs/heads/fix/issue_number" \
|
||||
"fix-issue-number"
|
||||
}
|
||||
|
||||
@test "slug_ref: a simple tag" {
|
||||
test_slug_ref \
|
||||
"refs/tags/v1.0.0" \
|
||||
"v1.0.0"
|
||||
}
|
||||
|
||||
@test "slug_ref: a complex tag" {
|
||||
test_slug_ref \
|
||||
"refs/tags/product@1.0.0-rc.2" \
|
||||
"product-1.0.0-rc.2"
|
||||
}
|
||||
|
||||
@test "slug_ref: a reference with upper case letters" {
|
||||
test_slug_ref \
|
||||
"refs/heads/New_Awesome_Product" \
|
||||
"new-awesome-product"
|
||||
}
|
||||
|
||||
@test "slug_ref: a very long name" {
|
||||
test_slug_ref \
|
||||
"refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters" \
|
||||
"an-awesome-feature-very-very-very-very-very-very-very-long-more"
|
||||
}
|
||||
|
||||
# Load sluf_ref function
|
||||
source entrypoint.sh > /dev/null 2>&1
|
||||
|
||||
test_slug_ref() {
|
||||
given="${1}"
|
||||
expected="${2}"
|
||||
|
||||
actual="$(slug_ref \"${given}\")"
|
||||
echo "expected : [${expected}], actual : [${actual}]"
|
||||
[ "${actual}" == "${expected}" ]
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
@test "slug_url: a word" {
|
||||
test_slug_url \
|
||||
"word" \
|
||||
"word"
|
||||
}
|
||||
|
||||
@test "slug_url: a string" {
|
||||
test_slug_url \
|
||||
"basic-string" \
|
||||
"basic-string"
|
||||
}
|
||||
|
||||
@test "slug_url: a string in camel case" {
|
||||
test_slug_url \
|
||||
"camelCase" \
|
||||
"camelcase"
|
||||
}
|
||||
|
||||
@test "slug_url: a path" {
|
||||
test_slug_url \
|
||||
"path/to/something" \
|
||||
"path-to-something"
|
||||
}
|
||||
|
||||
@test "slug_url: a number" {
|
||||
test_slug_url \
|
||||
"4.2" \
|
||||
"4-2"
|
||||
}
|
||||
|
||||
@test "slug_url: a very long string" {
|
||||
test_slug_url \
|
||||
"an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters" \
|
||||
"an-awesome-feature-very-very-very-very-very-very-very-long-more"
|
||||
}
|
||||
|
||||
# Load sluf_ref function
|
||||
source entrypoint.sh > /dev/null 2>&1
|
||||
|
||||
test_slug_url() {
|
||||
given="${1}"
|
||||
expected="${2}"
|
||||
|
||||
actual="$(slug_url \"${given}\")"
|
||||
echo "expected : [${expected}], actual : [${actual}]"
|
||||
[ "${actual}" == "${expected}" ]
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
@test "slug_url_ref: master branch" {
|
||||
test_slug_url_ref \
|
||||
"refs/heads/master" \
|
||||
"master"
|
||||
}
|
||||
|
||||
@test "slug_url_ref: a feature branch" {
|
||||
test_slug_url_ref \
|
||||
"refs/heads/feat/new_feature" \
|
||||
"feat-new-feature"
|
||||
}
|
||||
|
||||
@test "slug_url_ref: a fix branch" {
|
||||
test_slug_url_ref \
|
||||
"refs/heads/fix/issue_number" \
|
||||
"fix-issue-number"
|
||||
}
|
||||
|
||||
@test "slug_url_ref: a simple tag" {
|
||||
test_slug_url_ref \
|
||||
"refs/tags/v1.0.0" \
|
||||
"v1-0-0"
|
||||
}
|
||||
|
||||
@test "slug_url_ref: a complex tag" {
|
||||
test_slug_url_ref \
|
||||
"refs/tags/product@1.0.0-rc.2" \
|
||||
"product-1-0-0-rc-2"
|
||||
}
|
||||
|
||||
@test "slug_url_ref: a reference with upper case letters" {
|
||||
test_slug_url_ref \
|
||||
"refs/heads/New_Awesome_Product" \
|
||||
"new-awesome-product"
|
||||
}
|
||||
|
||||
@test "slug_url_ref: a very long name" {
|
||||
test_slug_url_ref \
|
||||
"refs/heads/an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters" \
|
||||
"an-awesome-feature-very-very-very-very-very-very-very-long-more"
|
||||
}
|
||||
|
||||
# Load sluf_ref function
|
||||
source entrypoint.sh > /dev/null 2>&1
|
||||
|
||||
test_slug_url_ref() {
|
||||
given="${1}"
|
||||
expected="${2}"
|
||||
|
||||
actual="$(slug_url_ref \"${given}\")"
|
||||
echo "expected : [${expected}], actual : [${actual}]"
|
||||
[ "${actual}" == "${expected}" ]
|
||||
}
|
||||
Reference in New Issue
Block a user