mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-06-10 08:40:58 +00:00
Compare commits
78 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
6
.dependabot/config.xml
Normal file
6
.dependabot/config.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
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 }}
|
|
||||||
313
.github/workflows/github-slug-action.yml
vendored
Normal file
313
.github/workflows/github-slug-action.yml
vendored
Normal file
@@ -0,0 +1,313 @@
|
|||||||
|
name: Github Slug Action testing
|
||||||
|
on: [push, pull_request]
|
||||||
|
jobs:
|
||||||
|
os-testing:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Load using v3.x
|
||||||
|
uses: rlespinasse/github-slug-action@v3.x
|
||||||
|
- name: Load using v4.x with prefix
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
prefix: V4_
|
||||||
|
short-length: 8
|
||||||
|
- name: Validate // Partial variables
|
||||||
|
run: |
|
||||||
|
echo "repository owner : ${{ env.V4_GITHUB_REPOSITORY_OWNER_PART }}"
|
||||||
|
echo "repository name : ${{ env.V4_GITHUB_REPOSITORY_NAME_PART }}"
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART }}" ]]
|
||||||
|
shell: bash
|
||||||
|
- name: Validate // Slug variables
|
||||||
|
run: |
|
||||||
|
echo "repository : ${{ env.V4_GITHUB_REPOSITORY_SLUG }}"
|
||||||
|
echo "repository owner : ${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG }}"
|
||||||
|
echo "repository name : ${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG }}"
|
||||||
|
echo "ref : ${{ env.V4_GITHUB_REF_SLUG }}"
|
||||||
|
echo "head ref : ${{ env.V4_GITHUB_HEAD_REF_SLUG }}"
|
||||||
|
echo "base ref : ${{ env.V4_GITHUB_BASE_REF_SLUG }}"
|
||||||
|
echo "event ref : ${{ env.V4_GITHUB_EVENT_REF_SLUG }}"
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REF_SLUG }}" == "${{ env.V4_GITHUB_REF_SLUG }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_HEAD_REF_SLUG }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_BASE_REF_SLUG }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_EVENT_REF_SLUG }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG }}" ]]
|
||||||
|
shell: bash
|
||||||
|
- name: Validate // Slug variables (Case Sensitive)
|
||||||
|
run: |
|
||||||
|
echo "repository : ${{ env.V4_GITHUB_REPOSITORY_SLUG_CS }}"
|
||||||
|
echo "repository owner : ${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}"
|
||||||
|
echo "repository name : ${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}"
|
||||||
|
echo "ref : ${{ env.V4_GITHUB_REF_SLUG_CS }}"
|
||||||
|
echo "head ref : ${{ env.V4_GITHUB_HEAD_REF_SLUG_CS }}"
|
||||||
|
echo "base ref : ${{ env.V4_GITHUB_BASE_REF_SLUG_CS }}"
|
||||||
|
echo "event ref : ${{ env.V4_GITHUB_EVENT_REF_SLUG_CS }}"
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_SLUG_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_HEAD_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_BASE_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_EVENT_REF_SLUG_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_CS }}" ]]
|
||||||
|
shell: bash
|
||||||
|
- name: Validate // Slug URL variables
|
||||||
|
run: |
|
||||||
|
echo "repository : ${{ env.V4_GITHUB_REPOSITORY_SLUG_URL }}"
|
||||||
|
echo "repository owner : ${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}"
|
||||||
|
echo "repository name : ${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}"
|
||||||
|
echo "ref : ${{ env.V4_GITHUB_REF_SLUG_URL }}"
|
||||||
|
echo "head ref : ${{ env.V4_GITHUB_HEAD_REF_SLUG_URL }}"
|
||||||
|
echo "base ref : ${{ env.V4_GITHUB_BASE_REF_SLUG_URL }}"
|
||||||
|
echo "event ref : ${{ env.V4_GITHUB_EVENT_REF_SLUG_URL }}"
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_URL }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_SLUG_URL }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_HEAD_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_URL }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_BASE_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_URL }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL }}" ]]
|
||||||
|
shell: bash
|
||||||
|
- name: Validate // Slug URL variables (Case Sensitive)
|
||||||
|
run: |
|
||||||
|
echo "repository : ${{ env.V4_GITHUB_REPOSITORY_SLUG_URL_CS }}"
|
||||||
|
echo "repository owner : ${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}"
|
||||||
|
echo "repository name : ${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}"
|
||||||
|
echo "ref : ${{ env.V4_GITHUB_REF_SLUG_URL_CS }}"
|
||||||
|
echo "head ref : ${{ env.V4_GITHUB_HEAD_REF_SLUG_URL_CS }}"
|
||||||
|
echo "base ref : ${{ env.V4_GITHUB_BASE_REF_SLUG_URL_CS }}"
|
||||||
|
echo "event ref : ${{ env.V4_GITHUB_EVENT_REF_SLUG_URL_CS }}"
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_SLUG_URL_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_SLUG_URL_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_HEAD_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_HEAD_REF_SLUG_URL_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_BASE_REF_SLUG_URL_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL_CS }}" ]]
|
||||||
|
shell: bash
|
||||||
|
- name: Validate // Ref Name
|
||||||
|
run: |
|
||||||
|
echo "raw : ${{ env.V4_GITHUB_REF_NAME }}"
|
||||||
|
echo "slug : ${{ env.V4_GITHUB_REF_NAME_SLUG }}"
|
||||||
|
echo "slug url : ${{ env.V4_GITHUB_REF_NAME_SLUG_URL }}"
|
||||||
|
echo "slug (Case Sensitive) : ${{ env.V4_GITHUB_REF_NAME_SLUG_CS }}"
|
||||||
|
echo "slug url (Case Sensitive) : ${{ env.V4_GITHUB_REF_NAME_SLUG_URL_CS }}"
|
||||||
|
[[ "${{ env.GITHUB_REF_NAME }}" == "${{ env.V4_GITHUB_REF_NAME }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REF_NAME_SLUG }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REF_NAME_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REF_NAME_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_CS }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_REF_NAME_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL_CS }}" ]]
|
||||||
|
shell: bash
|
||||||
|
- name: Validate // Short SHA variables
|
||||||
|
run: |
|
||||||
|
echo "sha : ${{ env.V4_GITHUB_SHA_SHORT }}"
|
||||||
|
echo "pull request sha : ${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
|
||||||
|
[[ "${{ env.GITHUB_SHA_SHORT }}" == "${{ env.V4_GITHUB_SHA_SHORT }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
os-testing-slug-maxlength:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Test 1
|
||||||
|
- name: Using correct 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 [ "$(echo "$value" | wc -m)" -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" | wc -l)" -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" | wc -l)" -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" | wc -l)" -gt 0 ]]
|
||||||
|
[[ "${{ steps.using-nolimit-slug-max-length.outcome }}" == "success" ]]
|
||||||
|
[[ "${{ steps.using-nolimit-slug-max-length.conclusion }}" == "success" ]]
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
os-testing-short-length:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Test 1
|
||||||
|
- name: Using correct 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 [ "$(echo "$value" | wc -m)" -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" | wc -l)" -eq 0 ]]
|
||||||
|
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
|
||||||
|
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
os-testing-without-checkout:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
path: this-action
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
- name: Load using v3.x
|
||||||
|
uses: rlespinasse/github-slug-action@v3.x
|
||||||
|
- name: Load using v4.x with prefix
|
||||||
|
uses: ./this-action
|
||||||
|
with:
|
||||||
|
prefix: V4_
|
||||||
|
short-length: 8
|
||||||
|
- name: Validate // Short SHA variables
|
||||||
|
run: |
|
||||||
|
echo "sha : ${{ env.V4_GITHUB_SHA_SHORT }}"
|
||||||
|
echo "pull request sha : ${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}"
|
||||||
|
[[ "${{ env.GITHUB_SHA_SHORT }}" == "${{ env.V4_GITHUB_SHA_SHORT }}" ]]
|
||||||
|
[[ "${{ env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" == "${{ env.V4_GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT }}" ]]
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
os-testing-short-length-without-checkout:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
path: this-action
|
||||||
|
ref: ${{ github.ref }}
|
||||||
|
|
||||||
|
# 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 [ "$(echo "$value" | wc -m)" -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" | wc -l)" -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" | wc -l)" -eq 0 ]]
|
||||||
|
[[ "${{ steps.using-wrong-short-length.outcome }}" == "failure" ]]
|
||||||
|
[[ "${{ steps.using-wrong-short-length.conclusion }}" == "success" ]]
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
concurrency:
|
||||||
|
group: release-${{ github.ref }}-${{ github.event_name }}
|
||||||
|
needs:
|
||||||
|
- os-testing
|
||||||
|
- os-testing-slug-maxlength
|
||||||
|
- os-testing-short-length
|
||||||
|
- os-testing-without-checkout
|
||||||
|
- os-testing-short-length-without-checkout
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Release this GitHub Action
|
||||||
|
uses: rlespinasse/release-that@v1
|
||||||
|
with:
|
||||||
|
without-prefix: true
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
node_modules/
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
# [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))
|
|
||||||
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"]
|
|
||||||
314
README.md
314
README.md
@@ -1,146 +1,258 @@
|
|||||||
# GitHub Slug action
|
# GitHub Slug action
|
||||||
|
|
||||||
[![Actions Status][1]][2]
|
[![Release][release-badge]][releases]
|
||||||
[![Public workflows that use this action.][8]][9]
|
![Lint][lint-badge]
|
||||||
|
[![Licence][license-badge]][license]
|
||||||
|
|
||||||
This action slug and expose some github variables.
|
This GitHub Action will expose the slug/short values of [some GitHub environment variables][github-env-vars] inside your GitHub workflow.
|
||||||
|
|
||||||
`Slug` a variable will
|
## Table of Contents
|
||||||
|
|
||||||
|
- [GitHub Slug action](#github-slug-action)
|
||||||
|
- [Table of Contents](#table-of-contents)
|
||||||
|
- [Overview](#overview)
|
||||||
|
- [Use this action](#use-this-action)
|
||||||
|
- [Migration from previous versions](#migration-from-previous-versions)
|
||||||
|
- [Available Environment variables](#available-environment-variables)
|
||||||
|
- [Enhanced variables](#enhanced-variables)
|
||||||
|
- [Partial variables](#partial-variables)
|
||||||
|
- [Slug variables](#slug-variables)
|
||||||
|
- [Slug URL variables](#slug-url-variables)
|
||||||
|
- [Short variables](#short-variables)
|
||||||
|
- [Troubleshooting](#troubleshooting)
|
||||||
|
- [The SHORT variables doesn't have the same lengths as before](#the-short-variables-doesnt-have-the-same-lengths-as-before)
|
||||||
|
- [One of the environment variables doesn't work as intended](#one-of-the-environment-variables-doesnt-work-as-intended)
|
||||||
|
- [An action could not be found at the URI](#an-action-could-not-be-found-at-the-uri)
|
||||||
|
- [Thanks for talking about us](#thanks-for-talking-about-us)
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
`SLUG` on a variable will
|
||||||
|
|
||||||
- put the variable content in lower case
|
- put the variable content in lower case
|
||||||
- replace any character by `-` except `0-9`, `a-z`, and `.`
|
- replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
||||||
- remove leading and trailing `-` character
|
- remove leading and trailing `-` character
|
||||||
- limit the string size to 63 characters
|
- limit the string size to 63 characters
|
||||||
|
|
||||||
Others `Slug`-ish commands are available:
|
<details>
|
||||||
|
<summary>Others <b>Slug-ish</b> commands are available</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
- `Slug URL` a variable will be like the `slug` variable but the `.` character will also be replaced by `-`
|
- `SLUG_URL` on a variable to have a `slug` variable compliant to be used in an URL
|
||||||
- `Short SHA` a variable will limit the string size to 8 characters
|
- Like `SLUG` but `.` is also replaced by `-`
|
||||||
|
- `SHORT` on a variable will limit the string size to ~8 characters
|
||||||
|
- Useful for _sha_ value
|
||||||
|
- `<KEY>_PART` on a variable will give a part of a variable defined by a key
|
||||||
|
- Like `GITHUB_REPOSITORY_OWNER_PART` for the owner part of `GITHUB_REPOSITORY`
|
||||||
|
- `<VAR>_CS` on others variables to keep the value case-sensitive
|
||||||
|
- Like `GITHUB_REF_SLUG_CS`
|
||||||
|
|
||||||
## Exposed environment variables
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
Additional enhanced environment variables can be compute to help you around GitHub environment variables.
|
||||||
|
|
||||||
|
## Use this action
|
||||||
|
|
||||||
|
Add this in your workflow
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Inject slug/short variables
|
- name: Inject slug/short variables
|
||||||
uses: rlespinasse/github-slug-action@v2.x
|
uses: rlespinasse/github-slug-action@v4
|
||||||
|
|
||||||
- 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 }}"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Read [default environment variables][3] page for more information.
|
Others configurations
|
||||||
|
|
||||||
### GITHUB_REF_SLUG / GITHUB_REF_SLUG_URL
|
- With a prefix
|
||||||
|
|
||||||
Slug the environment variable **GITHUB_REF**
|
```yaml
|
||||||
|
- name: Inject slug/short variables
|
||||||
|
uses: rlespinasse/github-slug-action@v4
|
||||||
|
with:
|
||||||
|
prefix: CI_
|
||||||
|
```
|
||||||
|
|
||||||
The branch or tag ref that triggered the workflow.
|
- With another max length for slug values
|
||||||
_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 |
|
```yaml
|
||||||
| ------------------------------ | ------------------- | ------------------- |
|
- name: Inject slug/short variables
|
||||||
| refs/heads/master | master | master |
|
uses: rlespinasse/github-slug-action@v4
|
||||||
| refs/heads/feat/new_feature | feat-new-feature | feat-new-feature |
|
with:
|
||||||
| refs/tags/v1.0.0 | v1.0.0 | v1-0-0 |
|
slug-maxlength: 80 # Use 'nolimit' to remove use of a max length (Default to 63)
|
||||||
| 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 :**
|
- With another length for short values
|
||||||
> GITHUB_REF_SLUG_URL is design to be used as subdomain in an URL.
|
|
||||||
|
|
||||||
_Additional variables (only set for forked repositories) :_
|
```yaml
|
||||||
|
- name: Inject slug/short variables
|
||||||
|
uses: rlespinasse/github-slug-action@v4
|
||||||
|
with:
|
||||||
|
short-length: 7 # By default it's up to git to decide, use 8 to have the v3.x behavior
|
||||||
|
```
|
||||||
|
|
||||||
- `GITHUB_HEAD_REF_SLUG`/`GITHUB_HEAD_REF_SLUG_URL`, The branch of the head repository **GITHUB_HEAD_REF**
|
**Warning**: If you leave it empty, you need to checkout the source first in order to let git decide the size by itself.
|
||||||
- `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) :_
|
Check for more [examples][examples] (OS usage, URL use, ...)
|
||||||
|
|
||||||
- `GITHUB_EVENT_REF_SLUG`/`GITHUB_EVENT_REF_SLUG_URL`, The git reference resource associated to the webhook.
|
**Tip:** Use [Dependabot][dependabot] to maintain your `github-slug-action` version updated in your GitHub workflows.
|
||||||
|
|
||||||
### GITHUB_REPOSITORY_SLUG / GITHUB_REPOSITORY_SLUG_URL
|
### Migration from previous versions
|
||||||
|
|
||||||
Slug the environment variable **GITHUB_REPOSITORY**
|
The short sha length is not the same as previous version.
|
||||||
|
|
||||||
The owner and repository name.
|
- `v4` let git configuration decide of it (but you can override it),
|
||||||
|
- `v3` and before, it's always a length of 8 characters.
|
||||||
|
|
||||||
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG | GITHUB_REPOSITORY_SLUG_URL |
|
So to reproduce previous behavior, use
|
||||||
| -------------------------- | -------------------------- | -------------------------- |
|
|
||||||
| 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*.
|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Inject slug/short variables
|
- name: Inject slug/short variables
|
||||||
uses: rlespinasse/github-slug-action@v2.x
|
uses: rlespinasse/github-slug-action@v4
|
||||||
|
with:
|
||||||
- name: Deploy dummy application using slug in the 'subdomain' part
|
short-length: 8 # Same as v3 and before
|
||||||
run: |
|
|
||||||
./deploy-application.sh --url "https://${{ env.<GITHUB_VARIABLE>_SLUG_URL }}.staging.app.mycompagny.com"
|
|
||||||
|
|
||||||
- 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 }}"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Available Environment variables
|
||||||
|
|
||||||
|
**Note**: If you don't find what you search for, read more about [available `GitHub` variables](docs/github-variables.md), and propose a [new custom variable][custom-variable].
|
||||||
|
|
||||||
|
### Enhanced variables
|
||||||
|
|
||||||
|
- `GITHUB_REF_NAME` will contains the reference name (branch or tag)
|
||||||
|
- based on `GITHUB_HEAD_REF` in a [`pull-request*`][webhooks-and-events] event context,
|
||||||
|
- based on `GITHUB_REF` in others event context.
|
||||||
|
|
||||||
|
**NOTE:** All enhanced variables are available in all **slug** formats.
|
||||||
|
|
||||||
|
### Partial variables
|
||||||
|
|
||||||
|
| Variable | Partial version of | Description |
|
||||||
|
| -------------------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------ |
|
||||||
|
| [GITHUB_REPOSITORY_OWNER_PART](docs/partial-variables.md#github_repository_owner_part) | GITHUB_REPOSITORY | The Owner part of GITHUB_REPOSITORY variable |
|
||||||
|
| [GITHUB_REPOSITORY_NAME_PART](docs/partial-variables.md#github_repository_name_part) | GITHUB_REPOSITORY | The Repository name part of GITHUB_REPOSITORY variable |
|
||||||
|
|
||||||
|
### Slug variables
|
||||||
|
|
||||||
|
**NOTE:** `_CS` suffix available
|
||||||
|
|
||||||
|
| Variable | Slug version of | Description |
|
||||||
|
| ------------------------------------------------------------------------------------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| [GITHUB_REPOSITORY_SLUG](docs/slug-variables.md#github_repository_slug) | GITHUB_REPOSITORY | The owner and repository name. |
|
||||||
|
| [GITHUB_REPOSITORY<br>_OWNER_PART_SLUG](docs/slug-variables.md#github_repository_owner_part_slug) | GITHUB_REPOSITORY_OWNER_PART | The owner name. |
|
||||||
|
| [GITHUB_REPOSITORY<br>_NAME_PART_SLUG](docs/slug-variables.md#github_repository_name_part_slug) | GITHUB_REPOSITORY_NAME_PART | The repository name. |
|
||||||
|
| [GITHUB_REF_SLUG](docs/slug-variables.md#github_ref_slug) | GITHUB_REF | The branch or tag ref that triggered the workflow. |
|
||||||
|
| [GITHUB_HEAD_REF_SLUG](docs/slug-variables.md#github_head_ref_slug) | GITHUB_HEAD_REF | The branch of the head repository.<br>Only set for [pull-request][event-pull-request] event and forked repositories. |
|
||||||
|
| [GITHUB_BASE_REF_SLUG](docs/slug-variables.md#github_base_ref_slug) | GITHUB_BASE_REF | The branch of the base repository.<br>Only set for [pull-request][event-pull-request] event and forked repositories. |
|
||||||
|
| [GITHUB_EVENT_REF_SLUG](docs/slug-variables.md#github_event_ref_slug) | _github.event.ref_ | <br>Only set for [following webhook events][webhooks-and-events]<ul><li>`create`</li><li>`delete`</li></ul> |
|
||||||
|
|
||||||
|
### Slug URL variables
|
||||||
|
|
||||||
|
**NOTE:** `_CS` suffix available
|
||||||
|
|
||||||
|
| Variable | Slug URL version of | Description |
|
||||||
|
| --------------------------------------------------------------------------------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| [GITHUB_REPOSITORY_SLUG_URL](docs/slug-url-variables.md#github_repository_slug_url) | GITHUB_REPOSITORY | The owner and repository name. |
|
||||||
|
| [GITHUB_REPOSITORY<br>_OWNER_PART_SLUG_URL](docs/slug-variables.md#github_repository_owner_part_slug_url) | GITHUB_REPOSITORY_OWNER_PART | The owner name. |
|
||||||
|
| [GITHUB_REPOSITORY<br>_NAME_PART_SLUG_URL](docs/slug-variables.md#github_repository_name_part_slug_url) | GITHUB_REPOSITORY_NAME_PART | The repository name. |
|
||||||
|
| [GITHUB_REF_SLUG_URL](docs/slug-url-variables.md#github_ref_slug_url) | GITHUB_REF | The branch or tag ref that triggered the workflow. |
|
||||||
|
| [GITHUB_HEAD_REF_SLUG_URL](docs/slug-url-variables.md#github_head_ref_slug_url) | GITHUB_HEAD_REF | The branch of the head repository.<br>Only set for [pull-request][webhooks-and-events] event and forked repositories. |
|
||||||
|
| [GITHUB_BASE_REF_SLUG_URL](docs/slug-url-variables.md#github_base_ref_slug_url) | GITHUB_BASE_REF | The branch of the base repository.<br>Only set for [pull-request][webhooks-and-events] event and forked repositories. |
|
||||||
|
| [GITHUB_EVENT_REF_SLUG_URL](docs/slug-url-variables.md#github_event_ref_slug_url) | _github.event.ref_ | <br>Only set for [following webhook events][webhooks-and-events]<ul><li>`create`</li><li>`delete`</li></ul> |
|
||||||
|
|
||||||
|
### Short variables
|
||||||
|
|
||||||
|
| Variable | Short version of | Description |
|
||||||
|
| -------------------------------------------------------------------------------------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| [GITHUB_SHA_SHORT](docs/short-variables.md#github_sha_short) | GITHUB_SHA | The commit SHA that triggered the workflow. |
|
||||||
|
| [GITHUB_EVENT<br>_PULL_REQUEST<br>_HEAD_SHA_SHORT](docs/short-variables.md#github_event_pull_request_head_sha_short) | _github.event<br>.pull_request<br>.head.sha_ | The commit SHA on pull request that trigger workflow.<br>Only set for [following webhook events][webhooks-and-events]<ul><li>`pull_request`</li><li>`pull_request_review`</li><li>`pull_request_review_comment`</li><li>`pull_request_target`</li></ul> |
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
### Missing master branch
|
### The SHORT variables doesn't have the same lengths as before
|
||||||
|
|
||||||
If your workflow fail on the `Set up job` task with this kind of log :
|
Since `v4`, it's git who manage the short variables by using [git rev-parse][git-revparse] behaviour.
|
||||||
|
The length of a short sha depends of the size of our repository and can differ over time.
|
||||||
|
|
||||||
```
|
To manage that moving length, you can use `short-length` input
|
||||||
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'
|
- set `7` to reproduce `small repository` behavior
|
||||||
|
- set `8` to reproduce `v3` behavior
|
||||||
|
|
||||||
|
**Warning**: The minimum length is 4, the default is the effective value of the [core.abbrev][git-core-abbrev] configuration variable.
|
||||||
|
|
||||||
|
### One of the environment variables doesn't work as intended
|
||||||
|
|
||||||
|
[**Note**][naming-conventions]: GitHub reserves the `GITHUB_` environment variable prefix for internal use by GitHub. Setting an environment variable or secret with the `GITHUB_` prefix will result in an error.
|
||||||
|
|
||||||
|
Currently, a GitHub workflow setting a `GITHUB_` variable will not cause an error, it will just fail silently.
|
||||||
|
And if a custom `GITHUB_` variable is in conflict with an official `GITHUB_` variable, the offical `GITHUB_` variable will override custom one.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Test workflow</summary>
|
||||||
|
<p>
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name: Test
|
||||||
|
on: push
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- run: echo ${GITHUB_REF}
|
||||||
|
# print "refs/heads/v4.x"
|
||||||
|
- run: echo "GITHUB_REF=one_value" >> "$GITHUB_ENV"
|
||||||
|
- run: echo ${GITHUB_REF}
|
||||||
|
# print "refs/heads/v4.x"
|
||||||
|
- run: echo "GITHUB_REF_SLUG=another_value" >> "$GITHUB_ENV"
|
||||||
|
- run: echo ${GITHUB_REF_SLUG}
|
||||||
|
# print "another_value"
|
||||||
```
|
```
|
||||||
|
|
||||||
Use the current branch `v2.x` or a version tag (see [releases pages][6]).
|
</p>
|
||||||
|
</details>
|
||||||
|
|
||||||
The master branch EOL is set on **2020-10-25** after a 6-month deprecation period (more information on the [EOL issue][7])
|
### An action could not be found at the URI
|
||||||
|
|
||||||
### Can't run on Windows or Macos
|
If your workflow fail on the `Set up job` task with this kind of log
|
||||||
|
|
||||||
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.
|
```text
|
||||||
Currently, this action don't support a system other than Linux due to Github Action Limitation on `Container`-based action.
|
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'
|
||||||
|
```
|
||||||
|
|
||||||
[1]: https://github.com/rlespinasse/github-slug-action/workflows/Build/badge.svg
|
If the `GIT_REFERENCE` value is
|
||||||
[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
|
|
||||||
|
|
||||||
|
- `v4.x` or after, the branch don't exists anymore following the [end-of-life for a branch](SECURITY.md#end-of-life-of-a-branch) security process.
|
||||||
|
- `master`, the branch don't exists anymore, read more about it on the corresponding issue ([EOL issue][issue-15])
|
||||||
|
|
||||||
|
Please, use the current major tag `v4` or a version tag (see [releases pages][releases]) in order to fix your workflow.
|
||||||
|
|
||||||
|
## Thanks for talking about us
|
||||||
|
|
||||||
|
- [Mettre en place une CI/CD Angular avec GitHub Actions & Netlify][article-1] (in french :fr:)
|
||||||
|
- [Github Actions : enfin des pipelines accessibles aux développeurs][talk-1] (in french :fr:)
|
||||||
|
- [Action spotlight by Michael Heap][article-2]
|
||||||
|
- The next one is you. _Don't hesitate to add youself to this list._
|
||||||
|
|
||||||
|
[release-badge]: https://img.shields.io/github/workflow/status/rlespinasse/github-slug-action/Release?label=Build&logo=github&style=flat-square
|
||||||
|
[lint-badge]: https://img.shields.io/github/workflow/status/rlespinasse/github-slug-action/Lint?label=Lint&logo=github&style=flat-square
|
||||||
|
[license-badge]: https://img.shields.io/github/license/rlespinasse/github-slug-action?style=flat-square
|
||||||
|
|
||||||
|
[actions]: https://github.com/rlespinasse/github-slug-action/actions
|
||||||
|
[license]: https://github.com/rlespinasse/github-slug-action/blob/v4.x/LICENSE
|
||||||
|
[examples]: https://github.com/rlespinasse/github-slug-action/tree/v4.x/examples
|
||||||
|
[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
|
||||||
|
|
||||||
|
[git-revpars]: 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
|
||||||
|
|
||||||
|
[github-env-vars]: https://docs.github.com/en/free-pro-team@latest/actions/reference/environment-variables#default-environment-variables
|
||||||
|
[dependabot]: https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot
|
||||||
|
[webhooks-and-events]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads
|
||||||
|
[naming-conventions]: https://docs.github.com/en/actions/reference/environment-variables#naming-conventions-for-environment-variables
|
||||||
|
|
||||||
|
[article-1]: https://esensconsulting.medium.com/mettre-en-place-une-ci-cd-angular-avec-github-actions-netlify-ca0b59b99ed8
|
||||||
|
[article-2]: https://michaelheap.com/github-slug-action/
|
||||||
|
[talk-1]: https://www.youtube.com/watch?v=RHnTJBwcE98
|
||||||
|
|||||||
22
SECURITY.md
22
SECURITY.md
@@ -2,14 +2,26 @@
|
|||||||
|
|
||||||
## Supported Versions and Branches
|
## Supported Versions and Branches
|
||||||
|
|
||||||
| Version | Branch | Supported |
|
We only support 2 major versions for security patches
|
||||||
|---------|--------|--------------------|
|
|
||||||
| 2.x | v2.x | :white_check_mark: |
|
| Version | Branch | Supported | Specific Tags |
|
||||||
| 1.1.x | v1.1.x | :white_check_mark: |
|
| ------- | ------ | ------------------ | ------------- |
|
||||||
| < 1.0.x | master | :x: |
|
| 4.x | v4.x | :white_check_mark: | v4 |
|
||||||
|
| 3.x | v3.x | :white_check_mark: | |
|
||||||
|
| < 2.x | | :x: | v2.x, v1.1.x |
|
||||||
|
|
||||||
A GitHub repository can used one of the available branches as action inside its workflows.
|
A GitHub repository can used one of the available branches as action inside its workflows.
|
||||||
|
|
||||||
|
### End of Life of a branch
|
||||||
|
|
||||||
|
When a branch is not supported anymore, the following process occurs
|
||||||
|
|
||||||
|
- Since `v4.x` branch, the branch will be deleted 2 major versions after
|
||||||
|
- So `v4.x` branch will be deleted when `v7.x` branch will have its first release
|
||||||
|
- prefer the `v4` tag to `v4.x` branch as reference in our workflow,
|
||||||
|
- Before `v4.x` branch, the branch will be converted into a tag when the support is dropped
|
||||||
|
- So `v3.x` branch will be converted as tag when `v5.x` branch will have its first release
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
You can report a Vulnerability by [my email](mailto:romain.lespinasse@gmail.com).
|
You can report a Vulnerability by [my email](mailto:romain.lespinasse@gmail.com).
|
||||||
|
|||||||
108
action.yml
108
action.yml
@@ -1,9 +1,101 @@
|
|||||||
# action.yml
|
name: "GitHub Slug Action"
|
||||||
name: "GitHub Slug"
|
description: "GitHub Action to expose slug value of environment variables inside your GitHub workflow"
|
||||||
description: "Action to slug and expose some github variables"
|
author: "Romain Lespinasse"
|
||||||
runs:
|
|
||||||
using: "docker"
|
|
||||||
image: "Dockerfile"
|
|
||||||
branding:
|
branding:
|
||||||
icon: "crop"
|
icon: "minimize"
|
||||||
color: "orange"
|
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 }}
|
||||||
|
|
||||||
|
- uses: rlespinasse/slugify-value@v1.2.1
|
||||||
|
with:
|
||||||
|
key: GITHUB_REPOSITORY
|
||||||
|
value: ${{ github.repository }}
|
||||||
|
prefix: ${{ inputs.prefix }}
|
||||||
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
|
- uses: rlespinasse/slugify-value@v1.2.1
|
||||||
|
with:
|
||||||
|
key: GITHUB_REF
|
||||||
|
prefix: ${{ inputs.prefix }}
|
||||||
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
|
- uses: rlespinasse/slugify-value@v1.2.0
|
||||||
|
with:
|
||||||
|
key: GITHUB_HEAD_REF
|
||||||
|
prefix: ${{ inputs.prefix }}
|
||||||
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
|
- uses: rlespinasse/slugify-value@v1.2.1
|
||||||
|
with:
|
||||||
|
key: GITHUB_BASE_REF
|
||||||
|
prefix: ${{ inputs.prefix }}
|
||||||
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
|
|
||||||
|
# Specific values
|
||||||
|
- uses: rlespinasse/slugify-value@v1.2.1
|
||||||
|
with:
|
||||||
|
key: GITHUB_EVENT_REF
|
||||||
|
value: ${{ github.event.ref }}
|
||||||
|
prefix: ${{ inputs.prefix }}
|
||||||
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
|
|
||||||
|
# Calculated values
|
||||||
|
- id: get-github-ref-name
|
||||||
|
run: echo "::set-output name=github-ref-name::$(echo "${{ github.head_ref || github.ref }}" | cut -d/ -f3)"
|
||||||
|
shell: bash
|
||||||
|
- uses: rlespinasse/slugify-value@v1.2.1
|
||||||
|
with:
|
||||||
|
key: GITHUB_REF_NAME
|
||||||
|
value: ${{ steps.get-github-ref-name.outputs.github-ref-name }}
|
||||||
|
prefix: ${{ inputs.prefix }}
|
||||||
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
|
- id: get-github-repository-owner-part
|
||||||
|
run: echo "::set-output name=github-repository-owner-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f1)"
|
||||||
|
shell: bash
|
||||||
|
- uses: rlespinasse/slugify-value@v1.2.1
|
||||||
|
with:
|
||||||
|
key: GITHUB_REPOSITORY_OWNER_PART
|
||||||
|
value: ${{ steps.get-github-repository-owner-part.outputs.github-repository-owner-part }}
|
||||||
|
prefix: ${{ inputs.prefix }}
|
||||||
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
|
- id: get-github-repository-name-part
|
||||||
|
run: echo "::set-output name=github-repository-name-part::$(echo $GITHUB_REPOSITORY | cut -d/ -f2)"
|
||||||
|
shell: bash
|
||||||
|
- uses: rlespinasse/slugify-value@v1.2.1
|
||||||
|
with:
|
||||||
|
key: GITHUB_REPOSITORY_NAME_PART
|
||||||
|
value: ${{ steps.get-github-repository-name-part.outputs.github-repository-name-part }}
|
||||||
|
prefix: ${{ inputs.prefix }}
|
||||||
|
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||||
|
|
||||||
|
# Short
|
||||||
|
- uses: rlespinasse/shortify-git-revision@v1.4.0
|
||||||
|
with:
|
||||||
|
name: GITHUB_SHA
|
||||||
|
short-on-error: true
|
||||||
|
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
|
||||||
|
prefix: ${{ inputs.prefix }}
|
||||||
|
- uses: rlespinasse/shortify-git-revision@v1.4.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 }}
|
||||||
|
|||||||
96
docs/github-variables.md
Normal file
96
docs/github-variables.md
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
# 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_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 |
|
||||||
109
docs/slug-url-variables.md
Normal file
109
docs/slug-url-variables.md
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
# 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_HEAD_REF_SLUG_URL](#github_head_ref_slug_url)
|
||||||
|
- [GITHUB_BASE_REF_SLUG_URL](#github_base_ref_slug_url)
|
||||||
|
- [GITHUB_EVENT_REF_SLUG_URL](#github_event_ref_slug_url)
|
||||||
|
|
||||||
|
## GITHUB_REPOSITORY_SLUG_URL
|
||||||
|
|
||||||
|
Slug URL the environment variable **GITHUB_REPOSITORY**
|
||||||
|
|
||||||
|
The owner and repository name.
|
||||||
|
|
||||||
|
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG_URL |
|
||||||
|
| ---------------------------- | ---------------------------- |
|
||||||
|
| octocat/Hello-World | octocat-hello-world |
|
||||||
|
| rlespinasse/Hello-World.go | rlespinasse-hello-world-go |
|
||||||
|
| AnotherPerson/SomeRepository | anotherperson-somerepository |
|
||||||
|
|
||||||
|
## GITHUB_REPOSITORY_OWNER_PART_SLUG_URL
|
||||||
|
|
||||||
|
Slug URL the environment variable [GITHUB_REPOSITORY_OWNER_PART](partial-variables.md#github_repository_owner_part)
|
||||||
|
|
||||||
|
The Owner part of **GITHUB_REPOSITORY** variable.
|
||||||
|
|
||||||
|
| GITHUB_REPOSITORY_OWNER_PART | GITHUB_REPOSITORY_OWNER_PART_SLUG_URL |
|
||||||
|
| ---------------------------- | ------------------------------------- |
|
||||||
|
| octocat | octocat |
|
||||||
|
| rlespinasse | rlespinasse |
|
||||||
|
| AnotherPerson | anotherperson |
|
||||||
|
|
||||||
|
## GITHUB_REPOSITORY_NAME_PART_SLUG_URL
|
||||||
|
|
||||||
|
Slug URL the environment variable [GITHUB_REPOSITORY_NAME_PART](partial-variables.md#github_repository_name_part)
|
||||||
|
|
||||||
|
The Repository name part of **GITHUB_REPOSITORY** variable.
|
||||||
|
|
||||||
|
| GITHUB_REPOSITORY_NAME_PART | GITHUB_REPOSITORY_NAME_PART_SLUG_URL |
|
||||||
|
| --------------------------- | ------------------------------------ |
|
||||||
|
| Hello-World | hello-world |
|
||||||
|
| Hello-World.go | hello-world-go |
|
||||||
|
| SomeRepository | somerepository |
|
||||||
|
|
||||||
|
## GITHUB_REF_SLUG_URL
|
||||||
|
|
||||||
|
Slug URL the environment variable **GITHUB_REF**
|
||||||
|
|
||||||
|
The branch or tag ref that triggered the workflow.
|
||||||
|
_If neither a branch or tag is available for the event type, the variable will not exist._
|
||||||
|
|
||||||
|
| GITHUB_REF | GITHUB_REF_SLUG_URL |
|
||||||
|
| ------------------------------ | ------------------- |
|
||||||
|
| refs/heads/main | main |
|
||||||
|
| refs/heads/feat/new_feature | feat-new-feature |
|
||||||
|
| refs/tags/v1.0.0 | v1-0-0 |
|
||||||
|
| refs/pull/42-merge | 42-merge |
|
||||||
|
| refs/tags/product@1.0.0-rc.2 | product-1-0-0-rc-2 |
|
||||||
|
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
**Caution**: From v3.0.0 to v3.2.0 included, `GITHUB_REF_SLUG` have the wrong value on `pull_request` event.
|
||||||
|
`refs/pull/42-merge` become `refs-pull-42-merge` instead of `42-merge`. The bug have been fixed in v3.3.0
|
||||||
|
|
||||||
|
## GITHUB_HEAD_REF_SLUG_URL
|
||||||
|
|
||||||
|
Slug URL the environment variable **GITHUB_HEAD_REF**
|
||||||
|
|
||||||
|
The branch of the head repository.
|
||||||
|
_Only set for forked repositories._
|
||||||
|
|
||||||
|
| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL |
|
||||||
|
| ------------------------------ | ------------------------ |
|
||||||
|
| refs/heads/main | main |
|
||||||
|
| refs/heads/feat/new_feature | feat-new-feature |
|
||||||
|
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
## GITHUB_BASE_REF_SLUG_URL
|
||||||
|
|
||||||
|
Slug URL the environment variable **GITHUB_BASE_REF**
|
||||||
|
|
||||||
|
The branch of the base repository.
|
||||||
|
_Only set for forked repositories._
|
||||||
|
|
||||||
|
| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL |
|
||||||
|
| ------------------------------ | ------------------------ |
|
||||||
|
| refs/heads/main | main |
|
||||||
|
| refs/heads/feat/new_feature | feat-new-feature |
|
||||||
|
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
## GITHUB_EVENT_REF_SLUG_URL
|
||||||
|
|
||||||
|
Slug URL the variable **github.event.ref**
|
||||||
|
|
||||||
|
The git reference resource associated to triggered webhook.
|
||||||
|
_Only set for [`create`, and `delete`][1] events._
|
||||||
|
|
||||||
|
| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL |
|
||||||
|
| ------------------------------ | ------------------------ |
|
||||||
|
| refs/heads/main | main |
|
||||||
|
| refs/heads/feat/new_feature | feat-new-feature |
|
||||||
|
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
[1]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads
|
||||||
105
docs/slug-variables.md
Normal file
105
docs/slug-variables.md
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
# 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_HEAD_REF_SLUG](#github_head_ref_slug)
|
||||||
|
- [GITHUB_BASE_REF_SLUG](#github_base_ref_slug)
|
||||||
|
- [GITHUB_EVENT_REF_SLUG](#github_event_ref_slug)
|
||||||
|
|
||||||
|
## GITHUB_REPOSITORY_SLUG
|
||||||
|
|
||||||
|
Slug the environment variable **GITHUB_REPOSITORY**
|
||||||
|
|
||||||
|
The owner and repository name.
|
||||||
|
|
||||||
|
| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG |
|
||||||
|
| ---------------------------- | ---------------------------- |
|
||||||
|
| octocat/Hello-World | octocat-hello-world |
|
||||||
|
| rlespinasse/Hello-World.go | rlespinasse-hello-world.go |
|
||||||
|
| AnotherPerson/SomeRepository | anotherperson-somerepository |
|
||||||
|
|
||||||
|
## GITHUB_REPOSITORY_OWNER_PART_SLUG
|
||||||
|
|
||||||
|
Slug the environment variable [GITHUB_REPOSITORY_OWNER_PART](partial-variables.md#github_repository_owner_part)
|
||||||
|
|
||||||
|
The Owner part of **GITHUB_REPOSITORY** variable.
|
||||||
|
|
||||||
|
| GITHUB_REPOSITORY_OWNER_PART | GITHUB_REPOSITORY_OWNER_PART_SLUG |
|
||||||
|
| ---------------------------- | --------------------------------- |
|
||||||
|
| octocat | octocat |
|
||||||
|
| rlespinasse | rlespinasse |
|
||||||
|
| AnotherPerson | anotherperson |
|
||||||
|
|
||||||
|
## GITHUB_REPOSITORY_NAME_PART_SLUG
|
||||||
|
|
||||||
|
Slug the environment variable [GITHUB_REPOSITORY_NAME_PART](partial-variables.md#github_repository_name_part)
|
||||||
|
|
||||||
|
The Repository name part of **GITHUB_REPOSITORY** variable.
|
||||||
|
|
||||||
|
| GITHUB_REPOSITORY_NAME_PART | GITHUB_REPOSITORY_NAME_PART_SLUG |
|
||||||
|
| --------------------------- | -------------------------------- |
|
||||||
|
| Hello-World | hello-world |
|
||||||
|
| Hello-World.go | hello-world.go |
|
||||||
|
| SomeRepository | somerepository |
|
||||||
|
|
||||||
|
## GITHUB_REF_SLUG
|
||||||
|
|
||||||
|
Slug the environment variable **GITHUB_REF**
|
||||||
|
|
||||||
|
The branch or tag ref that triggered the workflow.
|
||||||
|
_If neither a branch or tag is available for the event type, the variable will not exist._
|
||||||
|
|
||||||
|
| GITHUB_REF | GITHUB_REF_SLUG |
|
||||||
|
| ------------------------------ | ------------------- |
|
||||||
|
| refs/heads/main | main |
|
||||||
|
| refs/heads/feat/new_feature | feat-new-feature |
|
||||||
|
| refs/tags/v1.0.0 | v1.0.0 |
|
||||||
|
| refs/tags/product@1.0.0-rc.2 | product-1.0.0-rc.2 |
|
||||||
|
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
## GITHUB_HEAD_REF_SLUG
|
||||||
|
|
||||||
|
Slug the environment variable **GITHUB_HEAD_REF**
|
||||||
|
|
||||||
|
The branch of the head repository.
|
||||||
|
_Only set for [`pull-request`][1] event and forked repositories._
|
||||||
|
|
||||||
|
| GITHUB_REF | GITHUB_HEAD_REF_SLUG |
|
||||||
|
| ------------------------------ | -------------------- |
|
||||||
|
| refs/heads/main | main |
|
||||||
|
| refs/heads/feat/new_feature | feat-new-feature |
|
||||||
|
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
## GITHUB_BASE_REF_SLUG
|
||||||
|
|
||||||
|
Slug the environment variable **GITHUB_BASE_REF**
|
||||||
|
|
||||||
|
The branch of the base repository.
|
||||||
|
_Only set for [`pull-request`][1] event and forked repositories._
|
||||||
|
|
||||||
|
| GITHUB_REF | GITHUB_HEAD_REF_SLUG |
|
||||||
|
| ------------------------------ | -------------------- |
|
||||||
|
| refs/heads/main | main |
|
||||||
|
| refs/heads/feat/new_feature | feat-new-feature |
|
||||||
|
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
## GITHUB_EVENT_REF_SLUG
|
||||||
|
|
||||||
|
Slug the variable **github.event.ref**
|
||||||
|
|
||||||
|
The git reference resource associated to triggered webhook.
|
||||||
|
_Only set for [`create`, and `delete`][1] events._
|
||||||
|
|
||||||
|
| GITHUB_REF | GITHUB_HEAD_REF_SLUG |
|
||||||
|
| ------------------------------ | -------------------- |
|
||||||
|
| refs/heads/main | main |
|
||||||
|
| refs/heads/feat/new_feature | feat-new-feature |
|
||||||
|
| refs/heads/New_Awesome_Product | new-awesome-product |
|
||||||
|
|
||||||
|
[1]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads
|
||||||
@@ -1,55 +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 ::set-env name=GITHUB_REPOSITORY_SLUG::"$(slug "$GITHUB_REPOSITORY")"
|
|
||||||
echo ::set-env name=GITHUB_REPOSITORY_SLUG_URL::"$(slug_url "$GITHUB_REPOSITORY")"
|
|
||||||
|
|
||||||
echo ::set-env name=GITHUB_REF_SLUG::"$(slug_ref "$GITHUB_REF")"
|
|
||||||
echo ::set-env name=GITHUB_HEAD_REF_SLUG::"$(slug_ref "$GITHUB_HEAD_REF")"
|
|
||||||
echo ::set-env name=GITHUB_BASE_REF_SLUG::"$(slug_ref "$GITHUB_BASE_REF")"
|
|
||||||
echo ::set-env name=GITHUB_EVENT_REF_SLUG::"$(slug_ref "$(get_event_keyvalue "ref")")"
|
|
||||||
|
|
||||||
echo ::set-env name=GITHUB_REF_SLUG_URL::"$(slug_url_ref "$GITHUB_REF")"
|
|
||||||
echo ::set-env name=GITHUB_HEAD_REF_SLUG_URL::"$(slug_url_ref "$GITHUB_HEAD_REF")"
|
|
||||||
echo ::set-env name=GITHUB_BASE_REF_SLUG_URL::"$(slug_url_ref "$GITHUB_BASE_REF")"
|
|
||||||
echo ::set-env name=GITHUB_EVENT_REF_SLUG_URL::"$(slug_url_ref "$(get_event_keyvalue "ref")")"
|
|
||||||
|
|
||||||
echo ::set-env name=GITHUB_SHA_SHORT::"$(short_sha "$GITHUB_SHA")"
|
|
||||||
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@v2
|
||||||
|
- uses: rlespinasse/github-slug-action@v4
|
||||||
|
- 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@v2
|
||||||
|
- uses: rlespinasse/github-slug-action@v4
|
||||||
|
- 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@v2
|
||||||
|
- uses: rlespinasse/github-slug-action@v4
|
||||||
|
- run: |
|
||||||
|
./deploy-application.sh --url "https://${{ env.GITHUB_REF_SLUG_URL }}.staging.app.example.com"
|
||||||
|
|
||||||
|
as_resource_path:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: rlespinasse/github-slug-action@v4
|
||||||
|
- 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@v2
|
||||||
|
- uses: rlespinasse/github-slug-action@v4
|
||||||
|
- 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"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
34
preflight.sh
Executable file
34
preflight.sh
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/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"
|
||||||
|
echo "::set-output name=PREFLIGHT_SHORT_LENGTH::$PREFLIGHT_SHORT_LENGTH"
|
||||||
@@ -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