diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 017f2a1..056948d 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -25,6 +25,7 @@ jobs: uses: github/super-linter@v7 env: VALIDATE_ALL_CODEBASE: false + VALIDATE_JSCPD: false VALIDATE_JSON_PRETTIER: false VALIDATE_MARKDOWN_PRETTIER: false DEFAULT_BRANCH: v5.x diff --git a/.github/workflows/v5-tests-and-release.yml b/.github/workflows/v5-tests-and-release.yml index 167128b..d66a942 100644 --- a/.github/workflows/v5-tests-and-release.yml +++ b/.github/workflows/v5-tests-and-release.yml @@ -68,13 +68,13 @@ jobs: [[ "${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_EVENT_REF_SLUG_URL_CS }}" ]] shell: bash - - name: Validate // Ref Name + - name: Validate // Ref Point 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 }}" ]] + [[ "${{ env.GITHUB_REF_POINT }}" == "${{ env.V4_GITHUB_REF_NAME }}" ]] + [[ "${{ env.GITHUB_REF_POINT_SLUG }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG }}" ]] + [[ "${{ env.GITHUB_REF_POINT_SLUG_URL }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL }}" ]] + [[ "${{ env.GITHUB_REF_POINT_SLUG_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_CS }}" ]] + [[ "${{ env.GITHUB_REF_POINT_SLUG_URL_CS }}" == "${{ env.V4_GITHUB_REF_NAME_SLUG_URL_CS }}" ]] shell: bash - name: Validate // Short SHA variables @@ -139,6 +139,7 @@ jobs: echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}" echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG }}" echo "ref : ${{ env.GITHUB_REF_SLUG }}" + echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG }}" echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG }}" echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG }}" echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG }}" @@ -150,6 +151,7 @@ jobs: echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_CS }}" echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_CS }}" echo "ref : ${{ env.GITHUB_REF_SLUG_CS }}" + echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_CS }}" echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_CS }}" echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_CS }}" echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_CS }}" @@ -161,6 +163,7 @@ jobs: echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL }}" echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL }}" echo "ref : ${{ env.GITHUB_REF_SLUG_URL }}" + echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_URL }}" echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}" echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL }}" echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}" @@ -172,18 +175,19 @@ jobs: echo "repository owner : ${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG_URL_CS }}" echo "repository name : ${{ env.GITHUB_REPOSITORY_NAME_PART_SLUG_URL_CS }}" echo "ref : ${{ env.GITHUB_REF_SLUG_URL_CS }}" + echo "ref name : ${{ env.GITHUB_REF_NAME_SLUG_URL_CS }}" echo "head ref : ${{ env.GITHUB_HEAD_REF_SLUG_URL_CS }}" echo "base ref : ${{ env.GITHUB_BASE_REF_SLUG_URL_CS }}" echo "event ref : ${{ env.GITHUB_EVENT_REF_SLUG_URL_CS }}" shell: bash - - name: Ref Name + - name: Ref Point 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 }}" + echo "raw : ${{ env.GITHUB_REF_POINT }}" + echo "slug : ${{ env.GITHUB_REF_POINT_SLUG }}" + echo "slug url : ${{ env.GITHUB_REF_POINT_SLUG_URL }}" + echo "slug (Case Sensitive) : ${{ env.GITHUB_REF_POINT_SLUG_CS }}" + echo "slug url (Case Sensitive) : ${{ env.GITHUB_REF_POINT_SLUG_URL_CS }}" shell: bash - name: Short SHA variables diff --git a/README.md b/README.md index 44217db..7d918a2 100644 --- a/README.md +++ b/README.md @@ -2,27 +2,6 @@ This GitHub Action will expose the slug/short values of [some GitHub environment variables][default-environment-variables] inside your GitHub workflow. -## Table of Contents - -- [GitHub Slug action](#github-slug-action) - - [Table of Contents](#table-of-contents) - - [Overview](#overview) - - [Use this action](#use-this-action) - - [Migration from previous versions](#migration-from-previous-versions) - - [Available Environment variables](#available-environment-variables) - - [Enhanced variables](#enhanced-variables) - - [Partial variables](#partial-variables) - - [Slug variables](#slug-variables) - - [Slug URL variables](#slug-url-variables) - - [Short variables](#short-variables) - - [Troubleshooting](#troubleshooting) - - [The SHORT variables doesn't have the same lengths as before](#the-short-variables-doesnt-have-the-same-lengths-as-before) - - [One of the environment variables doesn't work as intended](#one-of-the-environment-variables-doesnt-work-as-intended) - - [Known environment variable conflicts](#known-environment-variable-conflicts) - - [GITHUB\_REF\_NAME](#github_ref_name) - - [An action could not be found at the URI](#an-action-could-not-be-found-at-the-uri) - - [Thanks for talking about us](#thanks-for-talking-about-us) - ## Overview `SLUG` on a variable will @@ -33,9 +12,7 @@ This GitHub Action will expose the slug/short values of [some GitHub environment - limit the string size to 63 characters - remove trailing `-` characters -
- Others Slug-ish commands are available -

+### Others Slug-ish variables are available - `SLUG_URL` on a variable to have a `slug` variable compliant to be used in a URL - Like `SLUG` but `.`, and `_` are also replaced by `-` @@ -46,133 +23,155 @@ This GitHub Action will expose the slug/short values of [some GitHub environment - `_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. -

-
- -## Use this action +## Installation -Add this in your workflow +Add this step to your workflow ```yaml -- name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v5 +steps: + - name: Inject enhanced GitHub environment variables + uses: rlespinasse/github-slug-action@v5 ``` -
- Others configurations -

+> [!CAUTION] +> Use [Dependabot][dependabot] to maintain your `github-slug-action` version updated in your GitHub workflows. + +## Configuration Options -- With a prefix +> [!TIP] +> Check for more [examples][examples] (OS usage, URL use, ...) - ```yaml - - name: Inject slug/short variables +### With a prefix + +```yaml +steps: + - name: Inject enhanced GitHub environment variables uses: rlespinasse/github-slug-action@v5 with: prefix: CI_ - ``` +``` -- With another max length for slug values +### With another max length for slug values - ```yaml - - name: Inject slug/short variables +```yaml +steps: + - name: Inject enhanced GitHub environment variables uses: rlespinasse/github-slug-action@v5 with: slug-maxlength: 80 # Use 'nolimit' to remove use of a max length (Default to 63) - ``` +``` -- With another length for short values +### With another length for short values - ```yaml - - name: Inject slug/short variables +```yaml +steps: + - name: Inject enhanced GitHub environment variables uses: rlespinasse/github-slug-action@v5 with: short-length: 7 # By default it's up to Git to decide, use 8 to have the v3.x behavior - ``` - - **Warning**: If you leave it empty, you need to checkout the source first in order to let Git decide the size by itself. -

-
- -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. - -- Since `v4` let Git configuration decide of it (but you can override it), -- With `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@v5 - with: - short-length: 8 # Same as v3 and before ``` +> [!WARNING] +> If you leave it empty, you need to checkout the source first in order to let Git decide the size by itself. + ## Available Environment variables -**Note**: If you don't find what you search for, read more about [available `GitHub` variables](docs/github-variables.md), and propose a [new custom variable][custom-variable]. +> [!TIP] +> If you don't find what you search for +> +> - Read more about [available `GitHub` variables](docs/github-variables.md), and propose a [new custom variable][custom-variable]. +> - Use your own variable with [slugify-value][slugify-value], or [shortify-git-revision][shortify-git-revision] for git reference. ### Enhanced variables -- `GITHUB_REF_NAME` will contains the reference name (branch or tag) +- `GITHUB_REF_POINT` will contains the reference name (branch or tag) - based on `GITHUB_HEAD_REF` in a [`pull-request*`][webhooks-and-events] event context, - - based on `GITHUB_REF` in others event context. + - based on `GITHUB_REF_NAME` in others event context. -**NOTE:** All enhanced variables are available in all **slug** formats. +> [!NOTE] +> All enhanced variables are available in all **slug** formats. ### Partial variables -| Variable | Partial version of | Description | -| -------------------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------ | -| [GITHUB_REPOSITORY_OWNER_PART](docs/partial-variables.md#github_repository_owner_part) | GITHUB_REPOSITORY | The Owner part of GITHUB_REPOSITORY variable | -| [GITHUB_REPOSITORY_NAME_PART](docs/partial-variables.md#github_repository_name_part) | GITHUB_REPOSITORY | The Repository name part of GITHUB_REPOSITORY variable | +| Variable | Description | +| -------- | ----------- | +| [GITHUB_REPOSITORY_OWNER_PART](docs/partial-variables.md#github_repository_owner_part) | The Owner part of GITHUB_REPOSITORY variable | +| [GITHUB_REPOSITORY_NAME_PART](docs/partial-variables.md#github_repository_name_part) | The Repository name part of GITHUB_REPOSITORY variable | ### Slug variables -**NOTE:** `_CS` suffix available +> [!TIP] +> Available in standard and case-sensitive (`_CS`) versions. + +| Variable | Description | +| -------- | ----------- | +| [GITHUB_REPOSITORY_SLUG](docs/slug-variables.md#github_repository_slug) | The owner and repository name. | +| [GITHUB_REPOSITORY_OWNER_PART_SLUG](docs/slug-variables.md#github_repository_owner_part_slug) | The owner name. | +| [GITHUB_REPOSITORY_NAME_PART_SLUG](docs/slug-variables.md#github_repository_name_part_slug) | The repository name. | +| [GITHUB_REF_SLUG](docs/slug-variables.md#github_ref_slug) | The branch or tag ref that triggered the workflow. | +| [GITHUB_REF_NAME_SLUG](docs/slug-variables.md#github_ref_name_slug) | This value matches the branch or tag name shown on GitHub. | +| [GITHUB_HEAD_REF_SLUG](docs/slug-variables.md#github_head_ref_slug) | The branch of the head repository. | +| [GITHUB_BASE_REF_SLUG](docs/slug-variables.md#github_base_ref_slug) | The branch of the base repository. | +| [GITHUB_EVENT_REF_SLUG](docs/slug-variables.md#github_event_ref_slug) | The Git reference resource associated to triggered webhook. | + +### URL-Safe Slug variables + +Same as slug variables but URL-compliant + +> [!TIP] +> Available in standard and case-sensitive (`_CS`) versions. + +| Variable | Description | +| -------- | ----------- | +| [GITHUB_REPOSITORY_SLUG_URL](docs/slug-url-variables.md#github_repository_slug_url) | The owner and repository name. | +| [GITHUB_REPOSITORY_OWNER_PART_SLUG_URL](docs/slug-variables.md#github_repository_owner_part_slug_url) | The owner name. | +| [GITHUB_REPOSITORY_NAME_PART_SLUG_URL](docs/slug-variables.md#github_repository_name_part_slug_url) | The repository name. | +| [GITHUB_REF_SLUG_URL](docs/slug-url-variables.md#github_ref_slug_url) | The branch or tag ref that triggered the workflow. | +| [GITHUB_REF_NAME_SLUG_URL](docs/slug-url-variables.md#github_ref_slug_url) | This value matches the branch or tag name shown on GitHub. | +| [GITHUB_HEAD_REF_SLUG_URL](docs/slug-url-variables.md#github_head_ref_slug_url) | The branch of the head repository. | +| [GITHUB_BASE_REF_SLUG_URL](docs/slug-url-variables.md#github_base_ref_slug_url) | The branch of the base repository. | +| [GITHUB_EVENT_REF_SLUG_URL](docs/slug-url-variables.md#github_event_ref_slug_url) | The Git reference resource associated to triggered webhook. | + +### Short variables -| Variable | Slug version of | Description | -| ------------------------------------------------------------------------------------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------- | -| [GITHUB_REPOSITORY_SLUG](docs/slug-variables.md#github_repository_slug) | GITHUB_REPOSITORY | The owner and repository name. | -| [GITHUB_REPOSITORY
_OWNER_PART_SLUG](docs/slug-variables.md#github_repository_owner_part_slug) | GITHUB_REPOSITORY_OWNER_PART | The owner name. | -| [GITHUB_REPOSITORY
_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.
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.
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_ |
Only set for [following webhook events][webhooks-and-events] | +| Variable | Description | +| -------- | ----------- | +| [GITHUB_SHA_SHORT](docs/short-variables.md#github_sha_short) | The commit SHA that triggered the workflow. | +| [GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT](docs/short-variables.md#github_event_pull_request_head_sha_short) | The commit SHA on pull request that trigger workflow. | -### Slug URL variables +## Migration from previous versions -**NOTE:** `_CS` suffix available +### v4 to v5 -| 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
_OWNER_PART_SLUG_URL](docs/slug-variables.md#github_repository_owner_part_slug_url) | GITHUB_REPOSITORY_OWNER_PART | The owner name. | -| [GITHUB_REPOSITORY
_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.
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.
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_ |
Only set for [following webhook events][webhooks-and-events] | +The **GITHUB_REF_NAME SLUG/SLUG_URL** variables doesn't work the same way as before -### Short variables +> [!TIP] +> If you use `v5` or related versions, you need to use `GITHUB_REF_POINT` instead of `GITHUB_REF_NAME` to get the behavior of the `v4` action. -| 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
_PULL_REQUEST
_HEAD_SHA_SHORT](docs/short-variables.md#github_event_pull_request_head_sha_short) | _github.event
.pull_request
.head.sha_ | The commit SHA on pull request that trigger workflow.
Only set for [following webhook events][webhooks-and-events] | +Before `v5`, the behavior was the same as the GitHub one except on `pull_request*` workflows ([Ready the full story][issue-104]). -## Troubleshooting +- `${{ env.GITHUB_REF_NAME }}` will serve the behavior of this action, +- `$GITHUB_REF_NAME` will serve the behavior of GitHub Action. + +On `pull_request*` workflows, the content will be `/merge` instead of the branch name. +So you need to use `GITHUB_REF_POINT` instead -### The SHORT variables doesn't have the same lengths as before +```yaml +steps: + - name: Inject enhanced GitHub environment variables + uses: rlespinasse/github-slug-action@v5 + - run: | + echo "Branch Name: ${GITHUB_REF_POINT}" + shell: bash + +``` -Since `v4`, it's Git who manage the short variables by using [git rev-parse][git-revparse] behaviour. +Then `${{ env.GITHUB_REF_POINT }}`, and `$GITHUB_REF_POINT` will serve the behavior of this action. +And `${{ env.GITHUB_REF_NAME }}`, and `$GITHUB_REF_NAME` will serve the behavior of GitHub Action. + +### v3 to v4 + +Since `v4`, it's Git who manage the short variables by using [`git rev-parse`][git-revparse] behaviour. The length of a short sha depends of the size of our repository and can differ over time. To manage that moving length, you can use `short-length` input @@ -180,11 +179,25 @@ 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. +> [!WARNING] +> The minimum length is 4, the default is the effective value of the [core.abbrev][git-core-abbrev] configuration variable. + +So to reproduce previous behavior, use + +```yaml +steps: + - name: Inject enhanced GitHub environment variables + uses: rlespinasse/github-slug-action@v5 + with: + short-length: 8 # Same as v3 and before +``` + +## Troubleshooting ### One of the environment variables doesn't work as intended -[**Note**][naming-conventions]: 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.** +> [!WARNING] +> When you set a custom environment variable, you [cannot use any of the default environment variable names][naming-conventions]. For a complete list of these, see [Default environment variables][default-environment-variables]. **If you attempt to override the value of one of these default environment variables, the assignment is ignored.** If a variable start to be used as default environment variable, the environment variable may have a different behavior than the expected one. @@ -196,30 +209,8 @@ If this append, the `${{ env.GITHUB_AWESOME_VARIABLE }}` and `$GITHUB_AWESOME_VA Otherwise the two expression will serve the behavior of this action. This will not occurs if you use the `prefix` input to avoid the issue. -**NOTE:** If detected, the maintainers of this action will choose the best course of action depending of the impact. - -#### Known environment variable conflicts - -##### GITHUB_REF_NAME - -The behavior is the same as the GitHub one except on `pull_request*` workflows ([Ready the full story][issue-104]). - -- `${{ env.GITHUB_REF_NAME }}` will serve the behavior of this action, -- `$GITHUB_REF_NAME` will serve the behavior of GitHub Action. - -On `pull_request*` workflows, the content will be `/merge` instead of the branch name. - -A possible workaround is to use `prefix` input - -```yaml -- name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v5 - with: - prefix: CI_ -``` - -Then `${{ env.CI_GITHUB_REF_NAME }}`, and `$CI_GITHUB_REF_NAME` will serve the behavior of this action. -And `$GITHUB_REF_NAME` will serve the behavior of GitHub Action. +> [!IMPORTANT] +> If detected, the maintainers of this action will choose the best course of action depending of the impact. ### An action could not be found at the URI @@ -262,6 +253,9 @@ In Chinese :cn: [issue-15]: https://github.com/rlespinasse/github-slug-action/issues/15 [issue-104]: https://github.com/rlespinasse/github-slug-action/issues/104 +[slugify-value]: https://github.com/rlespinasse/slugify-value +[shortify-git-revision]: https://github.com/rlespinasse/shortify-git-revision + [git-revparse]: https://git-scm.com/docs/git-rev-parse#Documentation/git-rev-parse.txt---shortlength [git-core-abbrev]: https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreabbrev diff --git a/action.yml b/action.yml index 6c540ac..e53a64b 100644 --- a/action.yml +++ b/action.yml @@ -59,7 +59,12 @@ runs: - uses: rlespinasse/slugify-value@v1.4.0 with: key: GITHUB_REF_NAME - # Related to https://github.com/rlespinasse/github-slug-action/issues/104 + value: ${{ github.ref_name }} + prefix: ${{ inputs.prefix }} + slug-maxlength: ${{ inputs.slug-maxlength }} + - uses: rlespinasse/slugify-value@v1.4.0 + with: + key: GITHUB_REF_POINT value: ${{ env.GITHUB_HEAD_REF_RAW || env.GITHUB_REF_NAME_RAW }} prefix: ${{ inputs.prefix }} slug-maxlength: ${{ inputs.slug-maxlength }} diff --git a/docs/github-variables.md b/docs/github-variables.md index 36cfb01..404af1a 100644 --- a/docs/github-variables.md +++ b/docs/github-variables.md @@ -12,10 +12,10 @@ All `GitHub` variables availables in your workflow in addition of ones exposed b - [Action-managed Event Variables](#action-managed-event-variables) - [create](#create) - [delete](#delete) - - [pull_request](#pull_request) - - [pull_request_review](#pull_request_review) - - [pull_request_review_comment](#pull_request_review_comment) - - [pull_request_target](#pull_request_target) + - [pull\_request](#pull_request) + - [pull\_request\_review](#pull_request_review) + - [pull\_request\_review\_comment](#pull_request_review_comment) + - [pull\_request\_target](#pull_request_target) ## Default environment variables @@ -23,13 +23,14 @@ Read the official documentation about [Default environment variables][1]. ### Action-managed Environment Variables -| Action-managed Variables | Can be suffix by | -| ------------------------ | -------------------- | -| GITHUB_REPOSITORY | `_SLUG`, `_SLUG_URL` | -| GITHUB_REF | `_SLUG`, `_SLUG_URL` | -| GITHUB_HEAD_REF | `_SLUG`, `_SLUG_URL` | -| GITHUB_BASE_REF | `_SLUG`, `_SLUG_URL` | -| GITHUB_SHA | `_SHORT` | +| Action-managed Variables | Can be suffix by | +| ------------------------ | --------------- | +| GITHUB_REPOSITORY | `_SLUG`, `_SLUG_URL` | +| GITHUB_REF | `_SLUG`, `_SLUG_URL` | +| GITHUB_REF_NAME | `_SLUG`, `_SLUG_URL` | +| GITHUB_HEAD_REF | `_SLUG`, `_SLUG_URL` | +| GITHUB_BASE_REF | `_SLUG`, `_SLUG_URL` | +| GITHUB_SHA | `_SHORT` | ## Variables from events @@ -41,50 +42,50 @@ Read the official documentation about [Events that trigger workflows][2]. Checkout [create][3] webhook payload content -| Action-managed Variables | Available as | -| ------------------------ | ------------------------- | -| github.event.ref | GITHUB_EVENT_REF_SLUG | -| github.event.ref | GITHUB_EVENT_REF_SLUG_URL | +| Action-managed Variables | Available as | +| ------------------------ | ------------ | +| github.event.ref | GITHUB_EVENT_REF_SLUG | +| github.event.ref | GITHUB_EVENT_REF_SLUG_URL | #### delete Checkout [delete][4] webhook payload content -| Action-managed Variables | Available as | -| ------------------------ | ------------------------- | -| github.event.ref | GITHUB_EVENT_REF_SLUG | -| github.event.ref | GITHUB_EVENT_REF_SLUG_URL | +| Action-managed Variables | Available as | +| ------------------------ | ------------ | +| github.event.ref | GITHUB_EVENT_REF_SLUG | +| github.event.ref | GITHUB_EVENT_REF_SLUG_URL | #### pull_request Checkout [pull_request][5] webhook payload content -| Action-managed Variables | Available as | -| ---------------------------------- | ---------------------------------------- | +| Action-managed Variables | Available as | +| ------------------------ | ------------ | | github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT | #### pull_request_review Checkout [pull_request_review][6] webhook payload content -| Action-managed Variables | Available as | -| ---------------------------------- | ---------------------------------------- | +| Action-managed Variables | Available as | +| ------------------------ | ------------ | | github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT | #### pull_request_review_comment Checkout [pull_request_review_comment][7] webhook payload content -| Action-managed Variables | Available as | -| ---------------------------------- | ---------------------------------------- | +| Action-managed Variables | Available as | +| ------------------------ | ------------ | | github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT | #### pull_request_target Checkout [pull_request][5] webhook payload content -| Action-managed Variables | Available as | -| ---------------------------------- | ---------------------------------------- | +| Action-managed Variables | Available as | +| ------------------------ | ------------ | | github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT | [1]: https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables diff --git a/docs/partial-variables.md b/docs/partial-variables.md index e29bf8a..931c60f 100644 --- a/docs/partial-variables.md +++ b/docs/partial-variables.md @@ -4,25 +4,25 @@ - [Partial Variables](#partial-variables) - [Table of Contents](#table-of-contents) - - [GITHUB_REPOSITORY_OWNER_PART](#github_repository_owner_part) - - [GITHUB_REPOSITORY_NAME_PART](#github_repository_name_part) + - [GITHUB\_REPOSITORY\_OWNER\_PART](#github_repository_owner_part) + - [GITHUB\_REPOSITORY\_NAME\_PART](#github_repository_name_part) ## GITHUB_REPOSITORY_OWNER_PART Owner part of the environment variable **GITHUB_REPOSITORY** -| GITHUB_REPOSITORY | GITHUB_REPOSITORY_OWNER_PART | -| ---------------------------- | ---------------------------- | -| octocat/Hello-World | octocat | -| rlespinasse/Hello-World.go | rlespinasse | -| AnotherPerson/SomeRepository | AnotherPerson | +| GITHUB_REPOSITORY | GITHUB_REPOSITORY_OWNER_PART | +| ----------------- | ---------------------------- | +| octocat/Hello-World | octocat | +| rlespinasse/Hello-World.go | rlespinasse | +| AnotherPerson/SomeRepository | AnotherPerson | ## GITHUB_REPOSITORY_NAME_PART Repository name part of the environment variable **GITHUB_REPOSITORY** -| GITHUB_REPOSITORY | GITHUB_REPOSITORY_NAME_PART | -| ---------------------------- | --------------------------- | -| octocat/Hello-World | Hello-World | -| rlespinasse/Hello-World.go | Hello-World.go | -| AnotherPerson/SomeRepository | SomeRepository | +| GITHUB_REPOSITORY | GITHUB_REPOSITORY_NAME_PART | +| ----------------- | --------------------------- | +| octocat/Hello-World | Hello-World | +| rlespinasse/Hello-World.go | Hello-World.go | +| AnotherPerson/SomeRepository | SomeRepository | diff --git a/docs/short-variables.md b/docs/short-variables.md index e42df1c..2c61a28 100644 --- a/docs/short-variables.md +++ b/docs/short-variables.md @@ -4,8 +4,8 @@ - [Short Variables](#short-variables) - [Table of Contents](#table-of-contents) - - [GITHUB_SHA_SHORT](#github_sha_short) - - [GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT](#github_event_pull_request_head_sha_short) + - [GITHUB\_SHA\_SHORT](#github_sha_short) + - [GITHUB\_EVENT\_PULL\_REQUEST\_HEAD\_SHA\_SHORT](#github_event_pull_request_head_sha_short) ## GITHUB_SHA_SHORT @@ -13,15 +13,15 @@ Short the environment variable **GITHUB_SHA** The commit SHA that triggered the workflow -| GITHUB_SHA | GITHUB_SHA_SHORT | -| ---------------------------------------- | ---------------- | -| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e | +| GITHUB_SHA | GITHUB_SHA_SHORT | +| ---------- | ---------------- | +| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e | ## GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT Short the value of `github.event.pull_request.head.sha` that represents the last commit used for triggering an action for a pull request. -| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT | -| ---------------------------------------- | ---------------------------------------- | -| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e | +| github.event.pull_request.head.sha | GITHUB_EVENT_PULL_REQUEST_HEAD_SHA_SHORT | +| ---------------------------------- | ---------------------------------------- | +| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e | diff --git a/docs/slug-url-variables.md b/docs/slug-url-variables.md index c06f2ae..efacb5b 100644 --- a/docs/slug-url-variables.md +++ b/docs/slug-url-variables.md @@ -4,13 +4,14 @@ - [Slug URL Variables](#slug-url-variables) - [Table of Contents](#table-of-contents) - - [GITHUB_REPOSITORY_SLUG_URL](#github_repository_slug_url) - - [GITHUB_REPOSITORY_OWNER_PART_SLUG_URL](#github_repository_owner_part_slug_url) - - [GITHUB_REPOSITORY_NAME_PART_SLUG_URL](#github_repository_name_part_slug_url) - - [GITHUB_REF_SLUG_URL](#github_ref_slug_url) - - [GITHUB_HEAD_REF_SLUG_URL](#github_head_ref_slug_url) - - [GITHUB_BASE_REF_SLUG_URL](#github_base_ref_slug_url) - - [GITHUB_EVENT_REF_SLUG_URL](#github_event_ref_slug_url) + - [GITHUB\_REPOSITORY\_SLUG\_URL](#github_repository_slug_url) + - [GITHUB\_REPOSITORY\_OWNER\_PART\_SLUG\_URL](#github_repository_owner_part_slug_url) + - [GITHUB\_REPOSITORY\_NAME\_PART\_SLUG\_URL](#github_repository_name_part_slug_url) + - [GITHUB\_REF\_SLUG\_URL](#github_ref_slug_url) + - [GITHUB\_REF\_NAME\_SLUG\_URL](#github_ref_name_slug_url) + - [GITHUB\_HEAD\_REF\_SLUG\_URL](#github_head_ref_slug_url) + - [GITHUB\_BASE\_REF\_SLUG\_URL](#github_base_ref_slug_url) + - [GITHUB\_EVENT\_REF\_SLUG\_URL](#github_event_ref_slug_url) ## GITHUB_REPOSITORY_SLUG_URL @@ -18,10 +19,10 @@ Slug URL the environment variable **GITHUB_REPOSITORY** The owner and repository name. -| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG_URL | -| ---------------------------- | ---------------------------- | -| octocat/Hello-World | octocat-hello-world | -| rlespinasse/Hello-World.go | rlespinasse-hello-world-go | +| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG_URL | +| ----------------- | ---------------------------- | +| octocat/Hello-World | octocat-hello-world | +| rlespinasse/Hello-World.go | rlespinasse-hello-world-go | | AnotherPerson/SomeRepository | anotherperson-somerepository | ## GITHUB_REPOSITORY_OWNER_PART_SLUG_URL @@ -32,9 +33,9 @@ The Owner part of **GITHUB_REPOSITORY** variable. | GITHUB_REPOSITORY_OWNER_PART | GITHUB_REPOSITORY_OWNER_PART_SLUG_URL | | ---------------------------- | ------------------------------------- | -| octocat | octocat | -| rlespinasse | rlespinasse | -| AnotherPerson | anotherperson | +| octocat | octocat | +| rlespinasse | rlespinasse | +| AnotherPerson | anotherperson | ## GITHUB_REPOSITORY_NAME_PART_SLUG_URL @@ -44,9 +45,9 @@ The Repository name part of **GITHUB_REPOSITORY** variable. | GITHUB_REPOSITORY_NAME_PART | GITHUB_REPOSITORY_NAME_PART_SLUG_URL | | --------------------------- | ------------------------------------ | -| Hello-World | hello-world | -| Hello-World.go | hello-world-go | -| SomeRepository | somerepository | +| Hello-World | hello-world | +| Hello-World.go | hello-world-go | +| SomeRepository | somerepository | ## GITHUB_REF_SLUG_URL @@ -55,17 +56,30 @@ Slug URL the environment variable **GITHUB_REF** The branch or tag ref that triggered the workflow. _If neither a branch or tag is available for the event type, the variable will not exist._ -| GITHUB_REF | GITHUB_REF_SLUG_URL | -| ------------------------------ | ------------------- | -| refs/heads/main | main | -| refs/heads/feat/new_feature | feat-new-feature | -| refs/tags/v1.0.0 | v1-0-0 | -| refs/pull/42-merge | 42-merge | -| refs/tags/product@1.0.0-rc.2 | product-1-0-0-rc-2 | +| GITHUB_REF | GITHUB_REF_SLUG_URL | +| ---------- | ------------------- | +| refs/heads/main | main | +| refs/heads/feat/new_feature | feat-new-feature | +| refs/tags/v1.0.0 | v1-0-0 | +| refs/pull/42/merge | 42-merge | +| refs/tags/product@1.0.0-rc.2 | product-1-0-0-rc-2 | | refs/heads/New_Awesome_Product | new-awesome-product | -**Caution**: From v3.0.0 to v3.2.0 included, `GITHUB_REF_SLUG` have the wrong value on `pull_request` event. -`refs/pull/42-merge` become `refs-pull-42-merge` instead of `42-merge`. The bug have been fixed in v3.3.0 +## GITHUB_REF_NAME_SLUG_URL + +Slug URL the environment variable **GITHUB_REF_NAME** + +The branch or tag ref that triggered the workflow. +_If neither a branch or tag is available for the event type, the variable will not exist._ + +| GITHUB_REF_NAME | GITHUB_REF_SLUG_URL | +| --------------- | ------------------- | +| refs/heads/main | main | +| refs/heads/feat/new_feature | feat-new-feature | +| refs/tags/v1.0.0 | v1-0-0 | +| refs/pull/42/merge | 42-merge | +| refs/tags/product@1.0.0-rc.2 | product-1-0-0-rc-2 | +| refs/heads/New_Awesome_Product | new-awesome-product | ## GITHUB_HEAD_REF_SLUG_URL @@ -74,11 +88,11 @@ Slug URL the environment variable **GITHUB_HEAD_REF** The branch of the head repository. _Only set for forked repositories._ -| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL | -| ------------------------------ | ------------------------ | -| refs/heads/main | main | -| refs/heads/feat/new_feature | feat-new-feature | -| refs/heads/New_Awesome_Product | new-awesome-product | +| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL | +| ---------- | ------------------------ | +| refs/heads/main | main | +| refs/heads/feat/new_feature | feat-new-feature | +| refs/heads/New_Awesome_Product | new-awesome-product | ## GITHUB_BASE_REF_SLUG_URL @@ -87,23 +101,23 @@ Slug URL the environment variable **GITHUB_BASE_REF** The branch of the base repository. _Only set for forked repositories._ -| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL | -| ------------------------------ | ------------------------ | -| refs/heads/main | main | -| refs/heads/feat/new_feature | feat-new-feature | -| refs/heads/New_Awesome_Product | new-awesome-product | +| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL | +| ---------- | ------------------------ | +| refs/heads/main | main | +| refs/heads/feat/new_feature | feat-new-feature | +| refs/heads/New_Awesome_Product | new-awesome-product | ## GITHUB_EVENT_REF_SLUG_URL Slug URL the variable **github.event.ref** -The git reference resource associated to triggered webhook. +The Git reference resource associated to triggered webhook. _Only set for [`create`, and `delete`][1] events._ -| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL | -| ------------------------------ | ------------------------ | -| refs/heads/main | main | -| refs/heads/feat/new_feature | feat-new-feature | -| refs/heads/New_Awesome_Product | new-awesome-product | +| GITHUB_REF | GITHUB_HEAD_REF_SLUG_URL | +| ---------- | ------------------------ | +| refs/heads/main | main | +| refs/heads/feat/new_feature | feat-new-feature | +| refs/heads/New_Awesome_Product | new-awesome-product | [1]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads diff --git a/docs/slug-variables.md b/docs/slug-variables.md index 9bd52c9..7079b83 100644 --- a/docs/slug-variables.md +++ b/docs/slug-variables.md @@ -4,13 +4,14 @@ - [Slug Variables](#slug-variables) - [Table of Contents](#table-of-contents) - - [GITHUB_REPOSITORY_SLUG](#github_repository_slug) - - [GITHUB_REPOSITORY_OWNER_PART_SLUG](#github_repository_owner_part_slug) - - [GITHUB_REPOSITORY_NAME_PART_SLUG](#github_repository_name_part_slug) - - [GITHUB_REF_SLUG](#github_ref_slug) - - [GITHUB_HEAD_REF_SLUG](#github_head_ref_slug) - - [GITHUB_BASE_REF_SLUG](#github_base_ref_slug) - - [GITHUB_EVENT_REF_SLUG](#github_event_ref_slug) + - [GITHUB\_REPOSITORY\_SLUG](#github_repository_slug) + - [GITHUB\_REPOSITORY\_OWNER\_PART\_SLUG](#github_repository_owner_part_slug) + - [GITHUB\_REPOSITORY\_NAME\_PART\_SLUG](#github_repository_name_part_slug) + - [GITHUB\_REF\_SLUG](#github_ref_slug) + - [GITHUB\_REF\_NAME\_SLUG](#github_ref_name_slug) + - [GITHUB\_HEAD\_REF\_SLUG](#github_head_ref_slug) + - [GITHUB\_BASE\_REF\_SLUG](#github_base_ref_slug) + - [GITHUB\_EVENT\_REF\_SLUG](#github_event_ref_slug) ## GITHUB_REPOSITORY_SLUG @@ -18,10 +19,10 @@ Slug the environment variable **GITHUB_REPOSITORY** The owner and repository name. -| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG | -| ---------------------------- | ---------------------------- | -| octocat/Hello-World | octocat-hello-world | -| rlespinasse/Hello-World.go | rlespinasse-hello-world.go | +| GITHUB_REPOSITORY | GITHUB_REPOSITORY_SLUG | +| ----------------- | ---------------------- | +| octocat/Hello-World | octocat-hello-world | +| rlespinasse/Hello-World.go | rlespinasse-hello-world.go | | AnotherPerson/SomeRepository | anotherperson-somerepository | ## GITHUB_REPOSITORY_OWNER_PART_SLUG @@ -32,9 +33,9 @@ The Owner part of **GITHUB_REPOSITORY** variable. | GITHUB_REPOSITORY_OWNER_PART | GITHUB_REPOSITORY_OWNER_PART_SLUG | | ---------------------------- | --------------------------------- | -| octocat | octocat | -| rlespinasse | rlespinasse | -| AnotherPerson | anotherperson | +| octocat | octocat | +| rlespinasse | rlespinasse | +| AnotherPerson | anotherperson | ## GITHUB_REPOSITORY_NAME_PART_SLUG @@ -44,9 +45,9 @@ The Repository name part of **GITHUB_REPOSITORY** variable. | GITHUB_REPOSITORY_NAME_PART | GITHUB_REPOSITORY_NAME_PART_SLUG | | --------------------------- | -------------------------------- | -| Hello-World | hello-world | -| Hello-World.go | hello-world.go | -| SomeRepository | somerepository | +| Hello-World | hello-world | +| Hello-World.go | hello-world.go | +| SomeRepository | somerepository | ## GITHUB_REF_SLUG @@ -55,14 +56,30 @@ Slug the environment variable **GITHUB_REF** The branch or tag ref that triggered the workflow. _If neither a branch or tag is available for the event type, the variable will not exist._ -| GITHUB_REF | GITHUB_REF_SLUG | -| ------------------------------ | ------------------- | -| refs/heads/main | main | -| refs/heads/feat/new_feature | feat-new-feature | -| refs/tags/v1.0.0 | v1.0.0 | -| refs/tags/product@1.0.0-rc.2 | product-1.0.0-rc.2 | +| GITHUB_REF | GITHUB_REF_SLUG | +| ---------- | --------------- | +| refs/heads/main | main | +| refs/heads/feat/new_feature | feat-new-feature | +| refs/tags/v1.0.0 | v1.0.0 | +| refs/tags/product@1.0.0-rc.2 | product-1.0.0-rc.2 | | refs/heads/New_Awesome_Product | new-awesome-product | +## GITHUB_REF_NAME_SLUG + +Slug the environment variable **GITHUB_REF_NAME** + +The branch or tag ref that triggered the workflow. +_If neither a branch or tag is available for the event type, the variable will not exist._ + +| GITHUB_REF_NAME | GITHUB_REF_SLUG | +| --------------- | --------------- | +| main | main | +| feat/new_feature | feat-new-feature | +| v1.0.0 | v1.0.0 | +| product@1.0.0-rc.2 | product-1.0.0-rc.2 | +| New_Awesome_Product | new-awesome-product | +| 42/merge | 42-merge | + ## GITHUB_HEAD_REF_SLUG Slug the environment variable **GITHUB_HEAD_REF** @@ -70,11 +87,11 @@ Slug the environment variable **GITHUB_HEAD_REF** The branch of the head repository. _Only set for [`pull-request`][1] event and forked repositories._ -| GITHUB_REF | GITHUB_HEAD_REF_SLUG | -| ------------------------------ | -------------------- | -| refs/heads/main | main | -| refs/heads/feat/new_feature | feat-new-feature | -| refs/heads/New_Awesome_Product | new-awesome-product | +| GITHUB_REF | GITHUB_HEAD_REF_SLUG | +| ---------- | -------------------- | +| refs/heads/main | main | +| refs/heads/feat/new_feature | feat-new-feature | +| refs/heads/New_Awesome_Product | new-awesome-product | ## GITHUB_BASE_REF_SLUG @@ -83,23 +100,23 @@ Slug the environment variable **GITHUB_BASE_REF** The branch of the base repository. _Only set for [`pull-request`][1] event and forked repositories._ -| GITHUB_REF | GITHUB_HEAD_REF_SLUG | -| ------------------------------ | -------------------- | -| refs/heads/main | main | -| refs/heads/feat/new_feature | feat-new-feature | -| refs/heads/New_Awesome_Product | new-awesome-product | +| GITHUB_REF | GITHUB_HEAD_REF_SLUG | +| ---------- | -------------------- | +| refs/heads/main | main | +| refs/heads/feat/new_feature | feat-new-feature | +| refs/heads/New_Awesome_Product | new-awesome-product | ## GITHUB_EVENT_REF_SLUG Slug the variable **github.event.ref** -The git reference resource associated to triggered webhook. +The Git reference resource associated to triggered webhook. _Only set for [`create`, and `delete`][1] events._ -| GITHUB_REF | GITHUB_HEAD_REF_SLUG | -| ------------------------------ | -------------------- | -| refs/heads/main | main | -| refs/heads/feat/new_feature | feat-new-feature | -| refs/heads/New_Awesome_Product | new-awesome-product | +| GITHUB_REF | GITHUB_HEAD_REF_SLUG | +| ---------- | -------------------- | +| refs/heads/main | main | +| refs/heads/feat/new_feature | feat-new-feature | +| refs/heads/New_Awesome_Product | new-awesome-product | [1]: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads