From f55abd0ed828b01504740c2beb8f895faca303e3 Mon Sep 17 00:00:00 2001 From: rlespinasse Date: Sat, 25 Apr 2020 22:03:21 +0200 Subject: [PATCH] docs: improve usage guide --- README.md | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index f41c85f..60cb9ad 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # GitHub Slug action +[![Actions Status](https://github.com/rlespinasse/github-slug-action/workflows/Build/badge.svg)](https://github.com/rlespinasse/github-slug-action/actions) + This action slug and expose some github variables. `Slug` a variable will @@ -10,24 +12,13 @@ This action slug and expose some github variables. - limit the string size to 63 characters. Others `Slug`-ish commands are available: + - `Short SHA` a variable will limit the string size to 8 characters. -## Environment Variables - -| GitHub environment variable | Slug variable | -| - | - | -| GITHUB_REF | GITHUB_REF_SLUG | -| GITHUB_HEAD_REF | GITHUB_HEAD_REF_SLUG | -| GITHUB_BASE_REF | GITHUB_BASE_REF_SLUG | - -| GitHub environment variable | Short variable | -| - | - | -| GITHUB_SHA | GITHUB_SHA_SHORT | - -## Example usage +## Exposed environment variables ```yaml -- uses: rlespinasse/github-slug-action@master +- uses: rlespinasse/github-slug-action@v1.1.x - name: Print slug variables run: | echo ${{ env.GITHUB_REF_SLUG }} @@ -35,3 +26,35 @@ Others `Slug`-ish commands are available: echo ${{ env.GITHUB_BASE_REF_SLUG }} echo ${{ env.GITHUB_SHA_SHORT }} ``` + +Read [default environment variables](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables) page for more information. + +### GITHUB_REF_SLUG + +Slug the environment variable **GITHUB_REF** + +The branch or tag ref that triggered the workflow. +_If neither a branch or tag is available for the event type, the variable will not exist._ + +| Environment variable (GITHUB_REF) | Slug variable (GITHUB_REF_SLUG) | +|-----------------------------------|---------------------------------| +| refs/heads/master | master | +| 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 | + +_Additional variables (only set for forked repositories) :_ + +- `GITHUB_HEAD_REF_SLUG` : The branch of the head repository **GITHUB_HEAD_REF**, +- `GITHUB_BASE_REF_SLUG` : The branch of the base repository **GITHUB_BASE_REF**. + +### GITHUB_SHA_SHORT + +Short the environment variable **GITHUB_SHA** + +The commit SHA that triggered the workflow + +| Environment variable (GITHUB_SHA) | Short variable (GITHUB_SHA_SHORT) | +|------------------------------------------|-----------------------------------| +| ffac537e6cbbf934b08745a378932722df287a53 | ffac537e |