mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-05-18 10:31:48 +00:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
@@ -1,3 +0,0 @@
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
@@ -1,54 +0,0 @@
|
||||
{
|
||||
"plugins": ["jest", "@typescript-eslint"],
|
||||
"extends": ["plugin:github/recommended"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 9,
|
||||
"sourceType": "module",
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"rules": {
|
||||
"eslint-comments/no-use": "off",
|
||||
"import/no-namespace": "off",
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": "error",
|
||||
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
|
||||
"@typescript-eslint/no-require-imports": "error",
|
||||
"@typescript-eslint/array-type": "error",
|
||||
"@typescript-eslint/await-thenable": "error",
|
||||
"@typescript-eslint/ban-ts-comment": "error",
|
||||
"camelcase": "off",
|
||||
"@typescript-eslint/consistent-type-assertions": "error",
|
||||
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
|
||||
"@typescript-eslint/func-call-spacing": ["error", "never"],
|
||||
"@typescript-eslint/no-array-constructor": "error",
|
||||
"@typescript-eslint/no-empty-interface": "error",
|
||||
"@typescript-eslint/no-explicit-any": "error",
|
||||
"@typescript-eslint/no-extraneous-class": "error",
|
||||
"@typescript-eslint/no-for-in-array": "error",
|
||||
"@typescript-eslint/no-inferrable-types": "error",
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
"@typescript-eslint/no-namespace": "error",
|
||||
"@typescript-eslint/no-non-null-assertion": "warn",
|
||||
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
||||
"@typescript-eslint/no-unnecessary-type-assertion": "error",
|
||||
"@typescript-eslint/no-useless-constructor": "error",
|
||||
"@typescript-eslint/no-var-requires": "error",
|
||||
"@typescript-eslint/prefer-for-of": "warn",
|
||||
"@typescript-eslint/prefer-function-type": "warn",
|
||||
"@typescript-eslint/prefer-includes": "error",
|
||||
"@typescript-eslint/prefer-string-starts-ends-with": "error",
|
||||
"@typescript-eslint/promise-function-async": "error",
|
||||
"@typescript-eslint/require-array-sort-compare": "error",
|
||||
"@typescript-eslint/restrict-plus-operands": "error",
|
||||
"semi": "off",
|
||||
"@typescript-eslint/semi": ["error", "never"],
|
||||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
"@typescript-eslint/unbound-method": "error"
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"jest/globals": true
|
||||
}
|
||||
}
|
||||
31
.github/workflows/codeql-analysis.yml
vendored
31
.github/workflows/codeql-analysis.yml
vendored
@@ -1,31 +0,0 @@
|
||||
name: '[v3] CodeQL'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- v3.x
|
||||
pull_request:
|
||||
branches:
|
||||
- v3.x
|
||||
schedule:
|
||||
- cron: '0 6 * * 1'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
analyse:
|
||||
name: analyze
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: ['javascript']
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
- uses: github/codeql-action/autobuild@v2
|
||||
- uses: github/codeql-action/analyze@v2
|
||||
74
.github/workflows/github-slug.yml
vendored
74
.github/workflows/github-slug.yml
vendored
@@ -1,74 +0,0 @@
|
||||
name: '[v3] Testing'
|
||||
on: [push]
|
||||
jobs:
|
||||
github-slug-on-os:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- run: npm install
|
||||
shell: bash
|
||||
- run: npm run all
|
||||
shell: bash
|
||||
- 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 "head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}"
|
||||
echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG }}"
|
||||
echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}"
|
||||
- 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 "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 "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 "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 Name
|
||||
run: |
|
||||
echo "raw : ${{ env.GITHUB_REF_NAME }}"
|
||||
echo "slug : ${{ env.GITHUB_REF_NAME_SLUG }}"
|
||||
echo "slug url : ${{ env.GITHUB_REF_NAME_SLUG_URL }}"
|
||||
echo "slug (Case Sensitive) : ${{ env.GITHUB_REF_NAME_SLUG_CS }}"
|
||||
echo "slug url (Case Sensitive) : ${{ env.GITHUB_REF_NAME_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
|
||||
29
.github/workflows/release-dryrun.yml
vendored
29
.github/workflows/release-dryrun.yml
vendored
@@ -1,29 +0,0 @@
|
||||
name: '[v3] Release DryRun'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- v*.x
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
release-dryrun:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: npm install
|
||||
shell: bash
|
||||
- run: npm run all
|
||||
shell: bash
|
||||
- uses: ./
|
||||
- uses: cycjimmy/semantic-release-action@v3
|
||||
with:
|
||||
branches: |
|
||||
[
|
||||
"${{ env.GITHUB_REF_NAME }}"
|
||||
]
|
||||
dry_run: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
22
.github/workflows/release.yml
vendored
22
.github/workflows/release.yml
vendored
@@ -1,22 +0,0 @@
|
||||
name: '[v3] Release'
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- v*.x
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: npm install
|
||||
shell: bash
|
||||
- run: npm run all
|
||||
shell: bash
|
||||
- uses: cycjimmy/semantic-release-action@v3
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
396
.github/workflows/v4-tests-and-release.yml
vendored
Normal file
396
.github/workflows/v4-tests-and-release.yml
vendored
Normal file
@@ -0,0 +1,396 @@
|
||||
name: '[v4] Test and Release'
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
check-v3compatibility:
|
||||
name: 'Check v3 compatibility'
|
||||
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 v4.x with prefix
|
||||
uses: ./
|
||||
with:
|
||||
prefix: V4_
|
||||
short-length: 8
|
||||
|
||||
- name: Load using v3.x
|
||||
uses: rlespinasse/github-slug-action@v3.x
|
||||
|
||||
- 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 Name
|
||||
run: |
|
||||
[[ "${{ 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: |
|
||||
[[ "${{ 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-v3compatibility-without-checkout:
|
||||
name: 'Check v3 compatibility (without checkout)'
|
||||
needs:
|
||||
- check-v3compatibility
|
||||
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 v4.x with prefix
|
||||
uses: ./this-action
|
||||
with:
|
||||
prefix: V4_
|
||||
short-length: 8
|
||||
|
||||
- name: Load using v3.x
|
||||
uses: rlespinasse/github-slug-action@v3.x
|
||||
|
||||
- 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@v3
|
||||
|
||||
- name: Load using v4.x
|
||||
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 "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 "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 "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 "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 Name
|
||||
run: |
|
||||
echo "raw : ${{ env.GITHUB_REF_NAME }}"
|
||||
echo "slug : ${{ env.GITHUB_REF_NAME_SLUG }}"
|
||||
echo "slug url : ${{ env.GITHUB_REF_NAME_SLUG_URL }}"
|
||||
echo "slug (Case Sensitive) : ${{ env.GITHUB_REF_NAME_SLUG_CS }}"
|
||||
echo "slug url (Case Sensitive) : ${{ env.GITHUB_REF_NAME_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@v3
|
||||
with:
|
||||
path: this-action
|
||||
ref: ${{ github.ref }}
|
||||
|
||||
- name: Load using v4.x with prefix
|
||||
uses: ./this-action
|
||||
with:
|
||||
prefix: V4_
|
||||
short-length: 8
|
||||
|
||||
- name: Load using v3.x
|
||||
uses: rlespinasse/github-slug-action@v3.x
|
||||
|
||||
- name: Short SHA variables
|
||||
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@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
|
||||
|
||||
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@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
|
||||
|
||||
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@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
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
concurrency:
|
||||
group: release-${{ github.ref }}-${{ github.event_name }}
|
||||
needs:
|
||||
- check-v3compatibility-without-checkout
|
||||
- display-without-checkout
|
||||
- input-short-length-without-checkout
|
||||
- input-slug-maxlength
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Release this GitHub Action
|
||||
uses: rlespinasse/release-that@v1
|
||||
99
.gitignore
vendored
99
.gitignore
vendored
@@ -1,99 +0,0 @@
|
||||
# Dependency directory
|
||||
node_modules
|
||||
|
||||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
*.lcov
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# TypeScript cache
|
||||
*.tsbuildinfo
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# OS metadata
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Ignore built ts files
|
||||
__tests__/runner/*
|
||||
lib/**/*
|
||||
@@ -1,3 +0,0 @@
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"printWidth": 80,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": false,
|
||||
"arrowParens": "avoid"
|
||||
}
|
||||
107
CHANGELOG.md
107
CHANGELOG.md
@@ -1,107 +0,0 @@
|
||||
# [3.8.0](https://github.com/rlespinasse/github-slug-action/compare/v3.7.1...v3.8.0) (2023-10-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* use node16 as action run mode ([7bf92d8](https://github.com/rlespinasse/github-slug-action/commit/7bf92d88ffb302024ab1f11ced51360f041f1b5e))
|
||||
|
||||
## [3.7.1](https://github.com/rlespinasse/github-slug-action/compare/v3.7.0...v3.7.1) (2022-10-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* use environment file to manage outputs ([dedf4ac](https://github.com/rlespinasse/github-slug-action/commit/dedf4ac5bbb50aeb6992c8323d2862843079f1b4))
|
||||
|
||||
# [3.7.0](https://github.com/rlespinasse/github-slug-action/compare/v3.6.1...v3.7.0) (2022-10-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* generate proper git tag ([68babf6](https://github.com/rlespinasse/github-slug-action/commit/68babf69b34f4c4b556ea350616c5408d627937e))
|
||||
|
||||
## [3.6.1](https://github.com/rlespinasse/github-slug-action/compare/3.6.0...3.6.1) (2022-08-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* remove trailing hyphens if any after cut ([19f9c84](https://github.com/rlespinasse/github-slug-action/commit/19f9c84ac61b17071a3cfc4ae984ac0e2ba1cdae))
|
||||
|
||||
# [3.6.0](http://github.com/rlespinasse/github-slug-action/compare/3.5.1...3.6.0) (2021-09-15)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add GITHUB_REF_NAME env var ([12a7510](http://github.com/rlespinasse/github-slug-action/commit/12a75106304d45442301df66d3ba38e1ac002649))
|
||||
|
||||
## [3.5.1](http://github.com/rlespinasse/github-slug-action/compare/3.5.0...3.5.1) (2021-03-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* update dist files ([e6c550f](http://github.com/rlespinasse/github-slug-action/commit/e6c550f88ccca52a82675b89186b6b72864f087c))
|
||||
|
||||
# [3.5.0](http://github.com/rlespinasse/github-slug-action/compare/3.4.0...3.5.0) (2021-03-30)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* allow underscore in slug values ([475d293](http://github.com/rlespinasse/github-slug-action/commit/475d293680b998a3315846828329f05bfff4ac9c))
|
||||
|
||||
# [3.4.0](http://github.com/rlespinasse/github-slug-action/compare/3.3.0...3.4.0) (2021-03-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add _CS suffix to keep value case-sensitive ([6c93fcb](http://github.com/rlespinasse/github-slug-action/commit/6c93fcbf53da9c6415bd7f5e37579b488f34339e))
|
||||
|
||||
# [3.3.0](http://github.com/rlespinasse/github-slug-action/compare/3.2.0...3.3.0) (2021-01-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* support pull-request for slug and slug url ([78985f8](http://github.com/rlespinasse/github-slug-action/commit/78985f84eca97ef1c5262e85e8a73a277494c4ed))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* support partial GITHUB_REPOSITORY ([75ce03b](http://github.com/rlespinasse/github-slug-action/commit/75ce03b6a055a3be9d936a3a99c51038bd72298c))
|
||||
|
||||
# [3.2.0](http://github.com/rlespinasse/github-slug-action/compare/3.1.0...3.2.0) (2021-01-12)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* expose GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT ([5b9fe60](http://github.com/rlespinasse/github-slug-action/commit/5b9fe6015d2facc71c81d53bf3b08f04e0f3f743))
|
||||
|
||||
# [3.1.0](http://github.com/rlespinasse/github-slug-action/compare/3.0.0...3.1.0) (2020-11-01)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **action:** improve marketplace information ([3cddc4f](http://github.com/rlespinasse/github-slug-action/commit/3cddc4f12d7a6fdbb8b1221dc02a2c64670e54bf))
|
||||
|
||||
# [3.0.0](http://github.com/rlespinasse/github-slug-action/compare/2.1.0...3.0.0) (2020-10-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* upgrade actions core due to CVE fix ([d0549c1](http://github.com/rlespinasse/github-slug-action/commit/d0549c1f85ab9567b439f9d660b01ce1142b9fbe))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add support for windows and macos jobs ([13c2f38](http://github.com/rlespinasse/github-slug-action/commit/13c2f38dad5f32529f37c25736412b1e4cf687fe))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* The action implementation move from container action to node.js action
|
||||
|
||||
Co-authored-by: Romain Lespinasse <romain.lespinasse@gmail.com>
|
||||
|
||||
# [2.1.0](http://github.com/rlespinasse/github-slug-action/compare/2.0.0...2.1.0) (2020-07-28)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* expose slug variables for github.event.ref ([5a334a8](http://github.com/rlespinasse/github-slug-action/commit/5a334a8573fc27451af5b2a6ee175d8e11579e10))
|
||||
@@ -18,7 +18,7 @@ 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] and start writing code (following the [developers guide](DEVELOPERS.md))
|
||||
* Suggest your change by [opening a 'Feature request' issue][5]
|
||||
|
||||
## Do you have questions about the source code
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
# Developers guide
|
||||
|
||||
## Prepare
|
||||
|
||||
Install the dependencies
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
## Develop
|
||||
|
||||
Build the typescript and package it for distribution
|
||||
|
||||
```bash
|
||||
npm run build && npm run package
|
||||
```
|
||||
|
||||
Run the tests
|
||||
|
||||
```bash
|
||||
$ npm test
|
||||
|
||||
PASS ./index.test.js
|
||||
✓ throws invalid number (3ms)
|
||||
✓ wait 500 ms (504ms)
|
||||
✓ test runs (95ms)
|
||||
|
||||
...
|
||||
```
|
||||
|
||||
## Contribute
|
||||
|
||||
Before creating a commit, validate your changes and build the associated distribution files
|
||||
|
||||
```bash
|
||||
npm run all
|
||||
```
|
||||
111
README.md
111
README.md
@@ -8,14 +8,15 @@ This GitHub Action will expose the slug/short values of [some GitHub environment
|
||||
- [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)
|
||||
- [Contribute](#contribute)
|
||||
- [Troubleshooting](#troubleshooting)
|
||||
- [The SHORT variables doesn't have the same lengths as before](#the-short-variables-doesnt-have-the-same-lengths-as-before)
|
||||
- [One of the environment variables doesn't work as intended](#one-of-the-environment-variables-doesnt-work-as-intended)
|
||||
- [Known environment variable conflicts](#known-environment-variable-conflicts)
|
||||
- [GITHUB_REF_NAME](#github_ref_name)
|
||||
@@ -37,32 +38,82 @@ This GitHub Action will expose the slug/short values of [some GitHub environment
|
||||
<p>
|
||||
|
||||
- `SLUG_URL` on a variable to have a `slug` variable compliant to be used in an URL
|
||||
- Like `SLUG` but `.` is also replaced by `-`
|
||||
- `SHORT` on a variable will limit the string size to 8 characters
|
||||
- Like `SLUG` but `.`, and `_` are also replaced by `-`
|
||||
- `SHORT` on a variable will limit the string size to ~8 characters
|
||||
- Useful for _sha_ value
|
||||
- `<KEY>_PART` on a variable will give a part of a variable defined by a key
|
||||
- Like `GITHUB_REPOSITORY_OWNER_PART` for the owner part of `GITHUB_REPOSITORY`
|
||||
- `<VAR>_CS` on others variables to keep the value case-sensitive
|
||||
- Like `GITHUB_REF_SLUG_CS`
|
||||
|
||||
Additional enhanced environment variables can be compute to help you around GitHub environment variables.
|
||||
</p>
|
||||
</details>
|
||||
|
||||
Additional enhanced environment variables can be compute to help you around GitHub environment variables.
|
||||
|
||||
## Use this action
|
||||
|
||||
Add this in your workflow
|
||||
|
||||
```yaml
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v3.x
|
||||
uses: rlespinasse/github-slug-action@v4
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Others configurations</summary>
|
||||
<p>
|
||||
|
||||
- With a prefix
|
||||
|
||||
```yaml
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v4
|
||||
with:
|
||||
prefix: CI_
|
||||
```
|
||||
|
||||
- With another max length for slug values
|
||||
|
||||
```yaml
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v4
|
||||
with:
|
||||
slug-maxlength: 80 # Use 'nolimit' to remove use of a max length (Default to 63)
|
||||
```
|
||||
|
||||
- With another length for short values
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
**Warning**: If you leave it empty, you need to checkout the source first in order to let git decide the size by itself.
|
||||
</p>
|
||||
</details>
|
||||
|
||||
Check for more [examples][examples] (OS usage, URL use, ...)
|
||||
|
||||
**Tip:** Use [Dependabot][dependabot] to maintain your `github-slug-action` version updated in your GitHub workflows.
|
||||
|
||||
### Migration from previous versions
|
||||
|
||||
The short sha length is not the same as previous version.
|
||||
|
||||
- `v4` let git configuration decide of it (but you can override it),
|
||||
- `v3` and before, it's always a length of 8 characters.
|
||||
|
||||
So to reproduce previous behavior, use
|
||||
|
||||
```yaml
|
||||
- name: Inject slug/short variables
|
||||
uses: rlespinasse/github-slug-action@v4
|
||||
with:
|
||||
short-length: 8 # Same as v3 and before
|
||||
```
|
||||
|
||||
## 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].
|
||||
@@ -117,12 +168,20 @@ Check for more [examples][examples] (OS usage, URL use, ...)
|
||||
| [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> |
|
||||
|
||||
## Contribute
|
||||
|
||||
Follow [Developers guide](DEVELOPERS.md)
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### The SHORT variables doesn't have the same lengths as before
|
||||
|
||||
Since `v4`, it's git who manage the short variables by using [git rev-parse][git-revparse] behaviour.
|
||||
The length of a short sha depends of the size of our repository and can differ over time.
|
||||
|
||||
To manage that moving length, you can use `short-length` input
|
||||
|
||||
- set `7` to reproduce `small repository` behavior
|
||||
- set `8` to reproduce `v3` behavior
|
||||
|
||||
**Warning**: The minimum length is 4, the default is the effective value of the [core.abbrev][git-core-abbrev] configuration variable.
|
||||
|
||||
### One of the environment variables doesn't work as intended
|
||||
|
||||
[**Note**][naming-conventions]: When you set a custom environment variable, you cannot use any of the default environment variable names. For a complete list of these, see [Default environment variables][default-environment-variables]. **If you attempt to override the value of one of these default environment variables, the assignment is ignored.**
|
||||
@@ -150,7 +209,7 @@ The behavior is the same as the GitHub one except on `pull_request*` workflows (
|
||||
|
||||
On `pull_request*` workflows, the content will be `<PR-number>/merge` instead of the branch name.
|
||||
|
||||
A possible workaround is to use `prefix` input available in `v4` version
|
||||
A possible workaround is to use `prefix` input
|
||||
|
||||
```yaml
|
||||
- name: Inject slug/short variables
|
||||
@@ -164,34 +223,38 @@ And `$GITHUB_REF_NAME` will serve the behavior of GitHub Action.
|
||||
|
||||
### An action could not be found at the URI
|
||||
|
||||
If your workflow fail on the `Set up job` task with this kind of log :
|
||||
If your workflow fail on the `Set up job` task with this kind of log
|
||||
|
||||
```text
|
||||
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'
|
||||
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'
|
||||
```
|
||||
|
||||
> The master branch doesn't exists anymore.
|
||||
>
|
||||
> The master branch EOL has been set to **2020-10-25** after a 6-month deprecation period (more information on the [EOL issue][issue-15])
|
||||
If the `GIT_REFERENCE` value is
|
||||
|
||||
Please, use the current branch `v3.x` or a version tag (see [releases pages][releases]) in order to fix your workflow.
|
||||
- `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]
|
||||
- [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]
|
||||
- [Github Actions : enfin des pipelines accessibles aux développeurs][talk-1] (in french :fr:)
|
||||
- The next one is you. _Don't hesitate to add youself to this list._
|
||||
|
||||
[actions]: https://github.com/rlespinasse/github-slug-action/actions
|
||||
[license]: https://github.com/rlespinasse/github-slug-action/blob/v3.x/LICENSE
|
||||
[examples]: https://github.com/rlespinasse/github-slug-action/tree/v3.x/examples
|
||||
[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
|
||||
[issue-104]: https://github.com/rlespinasse/github-slug-action/issues/104
|
||||
|
||||
[git-revparse]: https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---shortlength
|
||||
[git-core-abbrev]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreabbrev
|
||||
|
||||
[default-environment-variables]: https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
||||
[dependabot]: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot
|
||||
[webhooks-and-events]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads
|
||||
@@ -199,4 +262,6 @@ Please, use the current branch `v3.x` or a version tag (see [releases pages][rel
|
||||
|
||||
[article-1]: https://esensconsulting.medium.com/mettre-en-place-une-ci-cd-angular-avec-github-actions-netlify-ca0b59b99ed8
|
||||
[article-2]: https://michaelheap.com/github-slug-action/
|
||||
[talk-1]: https://www.youtube.com/watch?v=RHnTJBwcE98
|
||||
[article-3]: https://barstool.engineering/serverless-deploy-previews-on-github-actions/
|
||||
[article-4]: https://javascript.plainenglish.io/lets-build-a-continuous-delivery-and-branching-process-c27dae09f0b6
|
||||
[talk-1]: https://www.youtube.com/watch?v=F5mBDmOQcvE
|
||||
|
||||
23
SECURITY.md
23
SECURITY.md
@@ -2,15 +2,26 @@
|
||||
|
||||
## Supported Versions and Branches
|
||||
|
||||
| Version | Branch | Supported |
|
||||
|---------|--------|--------------------|
|
||||
| 3.x | v3.x | :white_check_mark: |
|
||||
| 2.x | v2.x | :white_check_mark: |
|
||||
| 1.1.x | v1.1.x | :x: |
|
||||
| < 1.x | | :x: |
|
||||
We only support 2 major versions for security patches
|
||||
|
||||
| Version | Branch | Supported | Specific Tags |
|
||||
| ------- | ------ | ------------------ | ------------- |
|
||||
| 4.x | v4.x | :white_check_mark: | v4 |
|
||||
| 3.x | v3.x | :white_check_mark: | |
|
||||
| < 2.x | | :x: | v2.x, v1.1.x |
|
||||
|
||||
A GitHub repository can used one of the available branches as action inside its workflows.
|
||||
|
||||
### 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
|
||||
|
||||
You can report a Vulnerability by [my email](mailto:romain.lespinasse@gmail.com).
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
import {sep} from 'path'
|
||||
import {get_first_part, get_second_part} from '../src/partial'
|
||||
|
||||
function test_get_first_part(
|
||||
input: string,
|
||||
separator: string,
|
||||
expected: string
|
||||
) {
|
||||
let actual = get_first_part(input, separator)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
function test_get_second_part(
|
||||
input: string,
|
||||
separator: string,
|
||||
expected: string
|
||||
) {
|
||||
let actual = get_second_part(input, separator)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
test('get_first_part', () => {
|
||||
test_get_first_part('first/second', '/', 'first')
|
||||
})
|
||||
|
||||
test('get_second_part', () => {
|
||||
test_get_second_part('first/second', '/', 'second')
|
||||
})
|
||||
@@ -1,10 +0,0 @@
|
||||
import {shortsha} from '../src/short'
|
||||
|
||||
function test_short_sha(input: string, expected: string) {
|
||||
let actual = shortsha(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
test('short_sha: long hash', () => {
|
||||
test_short_sha('a35a1a486a260cfd99c5b6f8c6034a2929ba9b3f', 'a35a1a48')
|
||||
})
|
||||
@@ -1,73 +0,0 @@
|
||||
import {slug, slug_cs} from '../src/slug'
|
||||
|
||||
function test_slug(input: string, expected: string) {
|
||||
let actual = slug(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
function test_slug_cs(input: string, expected: string) {
|
||||
let actual = slug_cs(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
test('slug: a word', () => {
|
||||
test_slug('word', 'word')
|
||||
test_slug_cs('word', 'word')
|
||||
})
|
||||
|
||||
test('slug: a string', () => {
|
||||
test_slug('basic-string', 'basic-string')
|
||||
test_slug_cs('basic-string', 'basic-string')
|
||||
})
|
||||
|
||||
test('slug: a string in camel case', () => {
|
||||
test_slug('camelCase', 'camelcase')
|
||||
test_slug_cs('camelCase', 'camelCase')
|
||||
})
|
||||
|
||||
test('slug: a path', () => {
|
||||
test_slug('path/to/something', 'path-to-something')
|
||||
test_slug_cs('path/to/something', 'path-to-something')
|
||||
})
|
||||
|
||||
test('slug: a number', () => {
|
||||
test_slug('4.2', '4.2')
|
||||
test_slug_cs('4.2', '4.2')
|
||||
})
|
||||
|
||||
test('slug: an underscore', () => {
|
||||
test_slug('An_Underscore', 'an_underscore')
|
||||
test_slug_cs('An_Underscore', 'An_Underscore')
|
||||
})
|
||||
|
||||
test('slug: special character', () => {
|
||||
test_slug('feat-(!è§-character', 'feat------character')
|
||||
test_slug_cs('feat-(!è§-character', 'feat------character')
|
||||
})
|
||||
|
||||
test('slug: trailing', () => {
|
||||
test_slug('-feat-trailing-', 'feat-trailing')
|
||||
test_slug_cs('-feat-trailing-', 'feat-trailing')
|
||||
})
|
||||
|
||||
test('slug: a very long string', () => {
|
||||
test_slug(
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||
)
|
||||
test_slug_cs(
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||
)
|
||||
})
|
||||
|
||||
test('slug: short string after trailing', () => {
|
||||
test_slug(
|
||||
'-has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters-',
|
||||
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||
)
|
||||
test_slug_cs(
|
||||
'-has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters-',
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||
)
|
||||
})
|
||||
@@ -1,72 +0,0 @@
|
||||
import {slugref, slugref_cs} from '../src/slug'
|
||||
|
||||
function test_slugref(input: string, expected: string) {
|
||||
let actual = slugref(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
function test_slugref_cs(input: string, expected: string) {
|
||||
let actual = slugref_cs(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
test('slug_ref:: master branch', () => {
|
||||
test_slugref('refs/heads/master', 'master')
|
||||
test_slugref_cs('refs/heads/master', 'master')
|
||||
})
|
||||
|
||||
test('slug_ref: a feature branch', () => {
|
||||
test_slugref('refs/heads/feat/new_feature', 'feat-new_feature')
|
||||
test_slugref_cs('refs/heads/feat/new_feature', 'feat-new_feature')
|
||||
})
|
||||
|
||||
test('slug_ref: a fix branch', () => {
|
||||
test_slugref('refs/heads/fix/issue_number', 'fix-issue_number')
|
||||
test_slugref_cs('refs/heads/fix/issue_number', 'fix-issue_number')
|
||||
})
|
||||
|
||||
test('slug_ref: an underscore', () => {
|
||||
test_slugref('refs/heads/An_Underscore', 'an_underscore')
|
||||
test_slugref_cs('refs/heads/An_Underscore', 'An_Underscore')
|
||||
})
|
||||
|
||||
test('slug_ref: a simple tag', () => {
|
||||
test_slugref('refs/tags/v1.0.0', 'v1.0.0')
|
||||
test_slugref_cs('refs/tags/v1.0.0', 'v1.0.0')
|
||||
})
|
||||
|
||||
test('slug_ref: a complex tag', () => {
|
||||
test_slugref('refs/tags/product@1.0.0-rc.2', 'product-1.0.0-rc.2')
|
||||
test_slugref_cs('refs/tags/product@1.0.0-rc.2', 'product-1.0.0-rc.2')
|
||||
})
|
||||
|
||||
test('slug_ref: a reference with upper case letters', () => {
|
||||
test_slugref('refs/heads/New_Awesome_Product', 'new_awesome_product')
|
||||
test_slugref_cs('refs/heads/New_Awesome_Product', 'New_Awesome_Product')
|
||||
})
|
||||
|
||||
test('slug_ref: test trailing', () => {
|
||||
test_slugref('refs/heads/-trailing-feat-', 'trailing-feat')
|
||||
test_slugref_cs('refs/heads/-trailing-feat-', 'trailing-feat')
|
||||
})
|
||||
|
||||
test('slug_ref: test refs inside string', () => {
|
||||
test_slugref('refs/heads/-refs/tags/feature/-', 'refs-tags-feature')
|
||||
test_slugref_cs('refs/heads/-refs/tags/feature/-', 'refs-tags-feature')
|
||||
})
|
||||
|
||||
test('slug_ref: a very long name', () => {
|
||||
test_slugref(
|
||||
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||
)
|
||||
test_slugref_cs(
|
||||
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||
)
|
||||
})
|
||||
|
||||
test('slug_ref: on pull-request ref', () => {
|
||||
test_slugref('refs/pull/branch', 'branch')
|
||||
test_slugref_cs('refs/pull/branch', 'branch')
|
||||
})
|
||||
@@ -1,57 +0,0 @@
|
||||
import {slugurl, slugurl_cs} from '../src/slug'
|
||||
|
||||
function test_slugurl(input: string, expected: string) {
|
||||
let actual = slugurl(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
function test_slugurl_cs(input: string, expected: string) {
|
||||
let actual = slugurl_cs(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
test('slug_url: a word', () => {
|
||||
test_slugurl('word', 'word')
|
||||
test_slugurl_cs('word', 'word')
|
||||
})
|
||||
|
||||
test('slug_url: a string', () => {
|
||||
test_slugurl('basic-string', 'basic-string')
|
||||
test_slugurl_cs('basic-string', 'basic-string')
|
||||
})
|
||||
|
||||
test('slug_url: a string in camel case', () => {
|
||||
test_slugurl('camelCase', 'camelcase')
|
||||
test_slugurl_cs('camelCase', 'camelCase')
|
||||
})
|
||||
|
||||
test('slug_url: a path', () => {
|
||||
test_slugurl('path/to/something', 'path-to-something')
|
||||
test_slugurl_cs('path/to/something', 'path-to-something')
|
||||
})
|
||||
|
||||
test('slug_url: a number', () => {
|
||||
test_slugurl('4.2', '4-2')
|
||||
test_slugurl_cs('4.2', '4-2')
|
||||
})
|
||||
|
||||
test('slug_url: an underscore', () => {
|
||||
test_slugurl('An_Underscore', 'an-underscore')
|
||||
test_slugurl_cs('An_Underscore', 'An-Underscore')
|
||||
})
|
||||
|
||||
test('slug_url: trailing', () => {
|
||||
test_slugurl('.path.to.', 'path-to')
|
||||
test_slugurl_cs('.path.to.', 'path-to')
|
||||
})
|
||||
|
||||
test('slug_url: a very long string', () => {
|
||||
test_slugurl(
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||
)
|
||||
test_slugurl_cs(
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||
)
|
||||
})
|
||||
@@ -1,72 +0,0 @@
|
||||
import {slugurlref, slugurlref_cs} from '../src/slug'
|
||||
|
||||
function test_slugurlref(input: string, expected: string) {
|
||||
let actual = slugurlref(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
function test_slugurlref_cs(input: string, expected: string) {
|
||||
let actual = slugurlref_cs(input)
|
||||
expect(actual).toEqual(expected)
|
||||
}
|
||||
|
||||
test('slug_url_ref: master branch', () => {
|
||||
test_slugurlref('refs/heads/master', 'master')
|
||||
test_slugurlref_cs('refs/heads/master', 'master')
|
||||
})
|
||||
|
||||
test('slug_url_ref: a feature branch', () => {
|
||||
test_slugurlref('refs/heads/feat/new_feature', 'feat-new-feature')
|
||||
test_slugurlref_cs('refs/heads/feat/new_feature', 'feat-new-feature')
|
||||
})
|
||||
|
||||
test('slug_url_ref: a fix branch', () => {
|
||||
test_slugurlref('refs/heads/fix/issue_number', 'fix-issue-number')
|
||||
test_slugurlref_cs('refs/heads/fix/issue_number', 'fix-issue-number')
|
||||
})
|
||||
|
||||
test('slug_url_ref: an underscore', () => {
|
||||
test_slugurlref('refs/heads/An_Underscore', 'an-underscore')
|
||||
test_slugurlref_cs('refs/heads/An_Underscore', 'An-Underscore')
|
||||
})
|
||||
|
||||
test('slug_url_ref: a simple tag', () => {
|
||||
test_slugurlref('refs/tags/v1.0.0', 'v1-0-0')
|
||||
test_slugurlref_cs('refs/tags/v1.0.0', 'v1-0-0')
|
||||
})
|
||||
|
||||
test('slug_url_ref: a complex tag', () => {
|
||||
test_slugurlref('refs/tags/product@1.0.0-rc.2', 'product-1-0-0-rc-2')
|
||||
test_slugurlref_cs('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_slugurlref('refs/heads/New_Awesome_Product', 'new-awesome-product')
|
||||
test_slugurlref_cs('refs/heads/New_Awesome_Product', 'New-Awesome-Product')
|
||||
})
|
||||
|
||||
test('slug_url_ref: a very long name', () => {
|
||||
test_slugurlref(
|
||||
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-feature-very-very-very-very-very-very-very-long'
|
||||
)
|
||||
test_slugurlref_cs(
|
||||
'refs/heads/has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long-moreThan63Characters',
|
||||
'has-an-awesome-Feature-Very-Very-Very-Very-Very-Very-Very-Long'
|
||||
)
|
||||
})
|
||||
|
||||
test('slug_url_ref: test trailing', () => {
|
||||
test_slugurlref('refs/heads/-an-awesome-Feature-', 'an-awesome-feature')
|
||||
test_slugurlref_cs('refs/heads/-an-awesome-Feature-', 'an-awesome-Feature')
|
||||
})
|
||||
|
||||
test('slug_url_ref: test trailing with dot', () => {
|
||||
test_slugurlref('refs/heads/.an-awesome-Feature.', 'an-awesome-feature')
|
||||
test_slugurlref_cs('refs/heads/.an-awesome-Feature.', 'an-awesome-Feature')
|
||||
})
|
||||
|
||||
test('slug_url_ref: on pull-request ref', () => {
|
||||
test_slugurlref('refs/pull/branch', 'branch')
|
||||
test_slugurlref_cs('refs/pull/branch', 'branch')
|
||||
})
|
||||
114
action.yml
114
action.yml
@@ -1,9 +1,115 @@
|
||||
name: "GitHub Slug Action"
|
||||
description: "GitHub Action to expose slug value of environment variables inside your GitHub workflow"
|
||||
author: 'rlespinasse'
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: 'dist/index.js'
|
||||
author: "Romain Lespinasse"
|
||||
branding:
|
||||
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@v1.4.0
|
||||
with:
|
||||
key: GITHUB_REPOSITORY
|
||||
value: ${{ github.repository }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- uses: rlespinasse/slugify-value@v1.4.0
|
||||
with:
|
||||
key: GITHUB_REF
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- uses: rlespinasse/slugify-value@v1.4.0
|
||||
with:
|
||||
key: GITHUB_HEAD_REF
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- uses: rlespinasse/slugify-value@v1.4.0
|
||||
with:
|
||||
key: GITHUB_BASE_REF
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
|
||||
# From Specific values
|
||||
- uses: rlespinasse/slugify-value@v1.4.0
|
||||
with:
|
||||
key: GITHUB_EVENT_REF
|
||||
value: ${{ github.event.ref }}
|
||||
prefix: ${{ inputs.prefix }}
|
||||
slug-maxlength: ${{ inputs.slug-maxlength }}
|
||||
- uses: rlespinasse/slugify-value@v1.4.0
|
||||
with:
|
||||
key: GITHUB_REF_NAME
|
||||
# Related to https://github.com/rlespinasse/github-slug-action/issues/104
|
||||
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@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@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@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@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 }}
|
||||
|
||||
3337
dist/index.js
vendored
3337
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
1
dist/index.js.map
vendored
1
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
1
dist/sourcemap-register.js
vendored
1
dist/sourcemap-register.js
vendored
File diff suppressed because one or more lines are too long
@@ -7,7 +7,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: rlespinasse/github-slug-action@v3.x
|
||||
- uses: rlespinasse/github-slug-action@v4
|
||||
- name: Output
|
||||
run: |
|
||||
echo "Partial variables"
|
||||
|
||||
@@ -7,7 +7,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: rlespinasse/github-slug-action@v3.x
|
||||
- uses: rlespinasse/github-slug-action@v4
|
||||
- name: Output
|
||||
run: |
|
||||
echo "Partial variables"
|
||||
|
||||
@@ -7,7 +7,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: rlespinasse/github-slug-action@v3.x
|
||||
- uses: rlespinasse/github-slug-action@v4
|
||||
- run: |
|
||||
./deploy-application.sh --url "https://${{ env.GITHUB_REF_SLUG_URL }}.staging.app.example.com"
|
||||
|
||||
@@ -15,6 +15,6 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: rlespinasse/github-slug-action@v3.x
|
||||
- uses: rlespinasse/github-slug-action@v4
|
||||
- run: |
|
||||
./deploy-application.sh --url "https://staging.app.example.com/${{ env.GITHUB_REF_SLUG_URL }}"
|
||||
|
||||
@@ -7,7 +7,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: rlespinasse/github-slug-action@v3.x
|
||||
- uses: rlespinasse/github-slug-action@v4
|
||||
- name: Output
|
||||
run: |
|
||||
echo "Partial variables"
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
module.exports = {
|
||||
clearMocks: true,
|
||||
moduleFileExtensions: ['js', 'ts'],
|
||||
testEnvironment: 'node',
|
||||
testMatch: ['**/*.test.ts'],
|
||||
testRunner: 'jest-circus/runner',
|
||||
transform: {
|
||||
'^.+\\.ts$': 'ts-jest'
|
||||
},
|
||||
verbose: true
|
||||
}
|
||||
13921
package-lock.json
generated
13921
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
72
package.json
72
package.json
@@ -1,72 +0,0 @@
|
||||
{
|
||||
"name": "github-slug-action",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"description": "Github slug action",
|
||||
"main": "lib/main.js",
|
||||
"scripts": {
|
||||
"release": "semantic-release",
|
||||
"build": "tsc",
|
||||
"format": "prettier --write **/*.ts",
|
||||
"format-check": "prettier --check **/*.ts",
|
||||
"lint": "eslint src/**/*.ts",
|
||||
"package": "ncc build --source-map",
|
||||
"test": "jest",
|
||||
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rlespinasse/github-slug-action.git"
|
||||
},
|
||||
"keywords": [
|
||||
"actions",
|
||||
"node",
|
||||
"setup"
|
||||
],
|
||||
"author": "rlespinasse",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@semantic-release/changelog": "^6.0.1",
|
||||
"@semantic-release/exec": "^6.0.0",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/node": "^14.18.25",
|
||||
"@typescript-eslint/eslint-plugin": "^5.38.1",
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-plugin-github": "^4.3.7",
|
||||
"eslint-plugin-jest": "^23.20.0",
|
||||
"jest": "^26.6.3",
|
||||
"jest-circus": "^26.6.3",
|
||||
"js-yaml": "^3.14.1",
|
||||
"prettier": "^2.7.1",
|
||||
"semantic-release": "^19.0.3",
|
||||
"ts-jest": "^26.5.6",
|
||||
"typescript": "^4.2.0"
|
||||
},
|
||||
"files": [
|
||||
"/dist"
|
||||
],
|
||||
"release": {
|
||||
"tagFormat": "v${version}",
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
"@semantic-release/release-notes-generator",
|
||||
"@semantic-release/changelog",
|
||||
[
|
||||
"@semantic-release/exec",
|
||||
{
|
||||
"prepareCmd": "git add dist"
|
||||
}
|
||||
],
|
||||
"@semantic-release/git",
|
||||
"@semantic-release/github"
|
||||
],
|
||||
"branches": [
|
||||
"v3.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
|
||||
401
src/main.ts
401
src/main.ts
@@ -1,401 +0,0 @@
|
||||
import * as core from '@actions/core'
|
||||
import {
|
||||
removeRef,
|
||||
slug,
|
||||
slug_cs,
|
||||
slugref,
|
||||
slugref_cs,
|
||||
slugurl,
|
||||
slugurl_cs,
|
||||
slugurlref,
|
||||
slugurlref_cs
|
||||
} from './slug'
|
||||
import {shortsha} from './short'
|
||||
import {get_first_part, get_second_part} from './partial'
|
||||
|
||||
const SEPARATOR = '/'
|
||||
|
||||
/**
|
||||
* Inputs environments variables keys from Github actions job
|
||||
* see https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
|
||||
*/
|
||||
const GITHUB_REPOSITORY = 'GITHUB_REPOSITORY'
|
||||
const GITHUB_REF = 'GITHUB_REF'
|
||||
const GITHUB_HEAD_REF = 'GITHUB_HEAD_REF'
|
||||
const GITHUB_BASE_REF = 'GITHUB_BASE_REF'
|
||||
const GITHUB_SHA = 'GITHUB_SHA'
|
||||
const GITHUB_EVENT_PATH = 'GITHUB_EVENT_PATH'
|
||||
|
||||
/**
|
||||
* Partial outputs environments variables keys
|
||||
*/
|
||||
const GITHUB_REPOSITORY_OWNER_PART = 'GITHUB_REPOSITORY_OWNER_PART'
|
||||
const GITHUB_REPOSITORY_NAME_PART = 'GITHUB_REPOSITORY_NAME_PART'
|
||||
|
||||
/**
|
||||
* New environments variables keys
|
||||
*/
|
||||
const GITHUB_REF_NAME = 'GITHUB_REF_NAME'
|
||||
|
||||
/**
|
||||
* Slugged outputs environments variables keys
|
||||
*/
|
||||
const GITHUB_REPOSITORY_SLUG = 'GITHUB_REPOSITORY_SLUG'
|
||||
const GITHUB_REPOSITORY_SLUG_CS = 'GITHUB_REPOSITORY_SLUG_CS'
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG = 'GITHUB_REPOSITORY_OWNER_PART_SLUG'
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG_CS =
|
||||
'GITHUB_REPOSITORY_OWNER_PART_SLUG_CS'
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG = 'GITHUB_REPOSITORY_NAME_PART_SLUG'
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG_CS =
|
||||
'GITHUB_REPOSITORY_NAME_PART_SLUG_CS'
|
||||
const GITHUB_REF_SLUG = 'GITHUB_REF_SLUG'
|
||||
const GITHUB_REF_SLUG_CS = 'GITHUB_REF_SLUG_CS'
|
||||
const GITHUB_HEAD_REF_SLUG = 'GITHUB_HEAD_REF_SLUG'
|
||||
const GITHUB_HEAD_REF_SLUG_CS = 'GITHUB_HEAD_REF_SLUG_CS'
|
||||
const GITHUB_BASE_REF_SLUG = 'GITHUB_BASE_REF_SLUG'
|
||||
const GITHUB_BASE_REF_SLUG_CS = 'GITHUB_BASE_REF_SLUG_CS'
|
||||
const GITHUB_EVENT_REF_SLUG = 'GITHUB_EVENT_REF_SLUG'
|
||||
const GITHUB_EVENT_REF_SLUG_CS = 'GITHUB_EVENT_REF_SLUG_CS'
|
||||
const GITHUB_REF_NAME_SLUG = 'GITHUB_REF_NAME_SLUG'
|
||||
const GITHUB_REF_NAME_SLUG_CS = 'GITHUB_REF_NAME_SLUG_CS'
|
||||
|
||||
/**
|
||||
* URL-Slugged outputs environments variables keys
|
||||
*/
|
||||
const GITHUB_REPOSITORY_SLUG_URL = 'GITHUB_REPOSITORY_SLUG_URL'
|
||||
const GITHUB_REPOSITORY_SLUG_URL_CS = 'GITHUB_REPOSITORY_SLUG_URL_CS'
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG_URL =
|
||||
'GITHUB_REPOSITORY_OWNER_PART_SLUG_URL'
|
||||
const GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS =
|
||||
'GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS'
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG_URL =
|
||||
'GITHUB_REPOSITORY_NAME_PART_SLUG_URL'
|
||||
const GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS =
|
||||
'GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS'
|
||||
const GITHUB_REF_SLUG_URL = 'GITHUB_REF_SLUG_URL'
|
||||
const GITHUB_REF_SLUG_URL_CS = 'GITHUB_REF_SLUG_URL_CS'
|
||||
const GITHUB_HEAD_REF_SLUG_URL = 'GITHUB_HEAD_REF_SLUG_URL'
|
||||
const GITHUB_HEAD_REF_SLUG_URL_CS = 'GITHUB_HEAD_REF_SLUG_URL_CS'
|
||||
const GITHUB_BASE_REF_SLUG_URL = 'GITHUB_BASE_REF_SLUG_URL'
|
||||
const GITHUB_BASE_REF_SLUG_URL_CS = 'GITHUB_BASE_REF_SLUG_URL_CS'
|
||||
const GITHUB_EVENT_REF_SLUG_URL = 'GITHUB_EVENT_REF_SLUG_URL'
|
||||
const GITHUB_EVENT_REF_SLUG_URL_CS = 'GITHUB_EVENT_REF_SLUG_URL_CS'
|
||||
const GITHUB_REF_NAME_SLUG_URL = 'GITHUB_REF_NAME_SLUG_URL'
|
||||
const GITHUB_REF_NAME_SLUG_URL_CS = 'GITHUB_REF_NAME_SLUG_URL_CS'
|
||||
|
||||
/**
|
||||
* Shorted outputs environments variables keys
|
||||
*/
|
||||
const GITHUB_SHA_SHORT = 'GITHUB_SHA_SHORT'
|
||||
const GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT =
|
||||
'GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT'
|
||||
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
const eventPath = process.env[GITHUB_EVENT_PATH]
|
||||
if (eventPath) {
|
||||
const eventData = await import(eventPath)
|
||||
if (eventData.hasOwnProperty('ref')) {
|
||||
core.exportVariable(GITHUB_EVENT_REF_SLUG, slugref(eventData.ref))
|
||||
core.exportVariable(GITHUB_EVENT_REF_SLUG_CS, slugref_cs(eventData.ref))
|
||||
core.exportVariable(
|
||||
GITHUB_EVENT_REF_SLUG_URL,
|
||||
slugurlref(eventData.ref)
|
||||
)
|
||||
core.exportVariable(
|
||||
GITHUB_EVENT_REF_SLUG_URL_CS,
|
||||
slugurlref_cs(eventData.ref)
|
||||
)
|
||||
} else if (eventData.hasOwnProperty('pull_request')) {
|
||||
core.exportVariable(
|
||||
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT,
|
||||
shortsha(eventData.pull_request.head.sha)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
exportFirstPart(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_OWNER_PART)
|
||||
exportSecondPart(GITHUB_REPOSITORY, SEPARATOR, GITHUB_REPOSITORY_NAME_PART)
|
||||
|
||||
exportSlug(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG)
|
||||
exportSlugCS(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_CS)
|
||||
exportFirstPartSlug(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_OWNER_PART_SLUG
|
||||
)
|
||||
exportFirstPartSlugCS(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_OWNER_PART_SLUG_CS
|
||||
)
|
||||
exportSecondPartSlug(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_NAME_PART_SLUG
|
||||
)
|
||||
exportSecondPartSlugCS(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_NAME_PART_SLUG_CS
|
||||
)
|
||||
|
||||
exportSlugUrl(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_URL)
|
||||
exportSlugUrlCS(GITHUB_REPOSITORY, GITHUB_REPOSITORY_SLUG_URL_CS)
|
||||
exportFirstPartSlugUrl(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_OWNER_PART_SLUG_URL
|
||||
)
|
||||
exportFirstPartSlugUrlCS(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS
|
||||
)
|
||||
exportSecondPartSlugUrl(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_NAME_PART_SLUG_URL
|
||||
)
|
||||
exportSecondPartSlugUrlCS(
|
||||
GITHUB_REPOSITORY,
|
||||
SEPARATOR,
|
||||
GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS
|
||||
)
|
||||
|
||||
exportSlugRef(GITHUB_REF, GITHUB_REF_SLUG)
|
||||
exportSlugRefCS(GITHUB_REF, GITHUB_REF_SLUG_CS)
|
||||
exportSlugRef(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG)
|
||||
exportSlugRefCS(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG_CS)
|
||||
exportSlugRef(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG)
|
||||
exportSlugRefCS(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG_CS)
|
||||
|
||||
exportSlugUrlRef(GITHUB_REF, GITHUB_REF_SLUG_URL)
|
||||
exportSlugUrlRefCS(GITHUB_REF, GITHUB_REF_SLUG_URL_CS)
|
||||
exportSlugUrlRef(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG_URL)
|
||||
exportSlugUrlRefCS(GITHUB_HEAD_REF, GITHUB_HEAD_REF_SLUG_URL_CS)
|
||||
exportSlugUrlRef(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG_URL)
|
||||
exportSlugUrlRefCS(GITHUB_BASE_REF, GITHUB_BASE_REF_SLUG_URL_CS)
|
||||
|
||||
exportShortSha(GITHUB_SHA, GITHUB_SHA_SHORT)
|
||||
|
||||
exportBranchName()
|
||||
} catch (error) {
|
||||
if (error instanceof Error) core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
function exportFirstPart(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, get_first_part(envVar, separator))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSecondPart(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, get_second_part(envVar, separator))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugCS(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slug_cs(envVar))
|
||||
}
|
||||
}
|
||||
function exportSlug(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slug(envVar))
|
||||
}
|
||||
}
|
||||
|
||||
function exportFirstPartSlugCS(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_first_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slug_cs(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportFirstPartSlug(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_first_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slug(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSecondPartSlugCS(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_second_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slug_cs(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSecondPartSlug(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_second_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slug(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugRefCS(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
exportSlugRefCSValue(envVar, outputKey)
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugRefCSValue(envVar: string, outputKey: string): void {
|
||||
core.exportVariable(outputKey, slugref_cs(envVar))
|
||||
}
|
||||
|
||||
function exportSlugRef(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
exportSlugRefValue(envVar, outputKey)
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugRefValue(envVar: string, outputKey: string): void {
|
||||
core.exportVariable(outputKey, slugref(envVar))
|
||||
}
|
||||
|
||||
function exportSlugUrlCS(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slugurl_cs(envVar))
|
||||
}
|
||||
}
|
||||
function exportSlugUrl(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, slugurl(envVar))
|
||||
}
|
||||
}
|
||||
|
||||
function exportFirstPartSlugUrlCS(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_first_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slugurl_cs(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportFirstPartSlugUrl(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_first_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slugurl(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSecondPartSlugUrlCS(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_second_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slugurl_cs(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSecondPartSlugUrl(
|
||||
inputKey: string,
|
||||
separator: string,
|
||||
outputKey: string
|
||||
): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
const value = get_second_part(envVar, separator)
|
||||
core.exportVariable(outputKey, slugurl(value))
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugUrlRefCS(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
exportSlugUrlRefCSValue(envVar, outputKey)
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugUrlRefCSValue(envVar: string, outputKey: string): void {
|
||||
core.exportVariable(outputKey, slugurlref_cs(envVar))
|
||||
}
|
||||
|
||||
function exportSlugUrlRef(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
exportSlugUrlRefValue(envVar, outputKey)
|
||||
}
|
||||
}
|
||||
|
||||
function exportSlugUrlRefValue(envVar: string, outputKey: string): void {
|
||||
core.exportVariable(outputKey, slugurlref(envVar))
|
||||
}
|
||||
|
||||
function exportShortSha(inputKey: string, outputKey: string): void {
|
||||
const envVar = process.env[inputKey]
|
||||
if (envVar) {
|
||||
core.exportVariable(outputKey, shortsha(envVar))
|
||||
}
|
||||
}
|
||||
|
||||
function exportBranchName(): void {
|
||||
//GITHUB_HEAD_REF is only set for pull request events https://docs.github.com/en/actions/reference/environment-variables
|
||||
const isPullRequest = !!process.env.GITHUB_HEAD_REF
|
||||
let refName
|
||||
if (isPullRequest) {
|
||||
refName = process.env.GITHUB_HEAD_REF
|
||||
} else {
|
||||
refName = process.env.GITHUB_REF
|
||||
}
|
||||
if (refName) {
|
||||
core.exportVariable(GITHUB_REF_NAME, removeRef(refName))
|
||||
exportSlugRefValue(refName, GITHUB_REF_NAME_SLUG)
|
||||
exportSlugRefCSValue(refName, GITHUB_REF_NAME_SLUG_CS)
|
||||
exportSlugUrlRefValue(refName, GITHUB_REF_NAME_SLUG_URL)
|
||||
exportSlugUrlRefCSValue(refName, GITHUB_REF_NAME_SLUG_URL_CS)
|
||||
}
|
||||
}
|
||||
|
||||
run()
|
||||
@@ -1,17 +0,0 @@
|
||||
/**
|
||||
* Get the first part of envVar
|
||||
* @param envVar to be split
|
||||
* @param separator of the split
|
||||
*/
|
||||
export function get_first_part(envVar: string, separator: string): string {
|
||||
return envVar.replace(RegExp(`${separator}.*$`), '')
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the second part of envVar
|
||||
* @param envVar to be split
|
||||
* @param separator of the split
|
||||
*/
|
||||
export function get_second_part(envVar: string, separator: string): string {
|
||||
return envVar.replace(RegExp(`^.*${separator}`), '')
|
||||
}
|
||||
10
src/short.ts
10
src/short.ts
@@ -1,10 +0,0 @@
|
||||
const SHORT_SHA_SIZE = 8
|
||||
|
||||
/**
|
||||
* slug will take envVar and then :
|
||||
* - limit the string size to 8 characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function shortsha(envVar: string): string {
|
||||
return envVar.substring(0, SHORT_SHA_SIZE)
|
||||
}
|
||||
129
src/slug.ts
129
src/slug.ts
@@ -1,129 +0,0 @@
|
||||
const MAX_SLUG_STRING_SIZE = 63
|
||||
|
||||
/**
|
||||
* slug_cs will take envVar and then :
|
||||
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slug_cs(envVar: string): string {
|
||||
return removeTrailingHyphens(
|
||||
removeLeadingHyphens(replaceAnyNonAlphanumericCharacter(envVar)).substring(
|
||||
0,
|
||||
MAX_SLUG_STRING_SIZE
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* slug will take envVar and then :
|
||||
* - put the variable content in lower case
|
||||
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slug(envVar: string): string {
|
||||
return slug_cs(envVar.toLowerCase())
|
||||
}
|
||||
|
||||
/**
|
||||
* slugref_cs will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugref_cs(envVar: string): string {
|
||||
return slug_cs(removeRef(envVar))
|
||||
}
|
||||
|
||||
/**
|
||||
* slugref will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - put the variable content in lower case
|
||||
* - replace any character by `-` except `0-9`, `a-z`, `.`, and `_`
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugref(envVar: string): string {
|
||||
return slugref_cs(envVar.toLowerCase())
|
||||
}
|
||||
|
||||
/**
|
||||
* slugurl_cs will take envVar and then :
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugurl_cs(envVar: string): string {
|
||||
return slug_cs(replaceAnyNonUrlCharactersWithHyphen(envVar))
|
||||
}
|
||||
|
||||
/**
|
||||
* slugurl will take envVar and then :
|
||||
* - put the variable content in lower case
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugurl(envVar: string): string {
|
||||
return slugurl_cs(envVar.toLowerCase())
|
||||
}
|
||||
|
||||
/**
|
||||
* slugurlref_cs will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugurlref_cs(envVar: string): string {
|
||||
return slugurl_cs(removeRef(envVar))
|
||||
}
|
||||
|
||||
/**
|
||||
* slugurlref will take envVar and then :
|
||||
* - remove refs/(heads|tags|pull)/
|
||||
* - put the variable content in lower case
|
||||
* - replace any character by `-` except `0-9`, `a-z`
|
||||
* - remove leading `-` characters
|
||||
* - limit the string size to 63 characters
|
||||
* - remove trailing `-` characters
|
||||
* @param envVar to be slugged
|
||||
*/
|
||||
export function slugurlref(envVar: string): string {
|
||||
return slugurlref_cs(envVar.toLowerCase())
|
||||
}
|
||||
|
||||
function removeLeadingHyphens(envVar: string): string {
|
||||
return envVar.replace(RegExp('^-*', 'g'), '')
|
||||
}
|
||||
function removeTrailingHyphens(envVar: string): string {
|
||||
return envVar.replace(RegExp('-*$', 'g'), '')
|
||||
}
|
||||
|
||||
function replaceAnyNonAlphanumericCharacter(envVar: string): string {
|
||||
return envVar.replace(RegExp('[^a-zA-Z0-9._]', 'g'), '-')
|
||||
}
|
||||
|
||||
function replaceAnyNonUrlCharactersWithHyphen(envVar: string): string {
|
||||
return envVar.replace(RegExp('[._]', 'g'), '-')
|
||||
}
|
||||
|
||||
export function removeRef(envVar: string): string {
|
||||
return envVar.replace(RegExp('^refs/(heads|tags|pull)/'), '')
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
"outDir": "./lib", /* Redirect output structure to the directory. */
|
||||
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
||||
},
|
||||
"exclude": ["node_modules", "**/*.test.ts"]
|
||||
}
|
||||
Reference in New Issue
Block a user