DEV Community

Romain Lespinasse
Romain Lespinasse

Posted on Edited on

Use Slug variables for your release and deployment workflows

My Workflow

Want to use the branch name in an url during a deployment? Want to use a commit hash in a release process?

Slug it.

This action give you access to multiple slug version of some GitHub variables to be use on your release or deployment workflows.

Submission Category:

  • Maintainer Must-Haves
  • DIY Deployments

Yaml File or Link to Code

This action source code is available on https://github.com/rlespinasse/github-slug-action

- name: Inject slug/short variables
  uses: rlespinasse/github-slug-action@v2.x

- name: Print slug/short variables
  run: |
    echo "Slug variables"
    echo "   ref        : ${{ env.GITHUB_REF_SLUG }}"
    echo "   head ref   : ${{ env.GITHUB_HEAD_REF_SLUG }}"
    echo "   base ref   : ${{ env.GITHUB_BASE_REF_SLUG }}"
    echo "   event ref  : ${{ env.GITHUB_EVENT_REF_SLUG }}"
    echo "   repository : ${{ env.GITHUB_REPOSITORY_SLUG }}"
    echo "Slug URL variables"
    echo "   ref        : ${{ env.GITHUB_REF_SLUG_URL }}"
    echo "   head ref   : ${{ env.GITHUB_HEAD_REF_SLUG_URL }}"
    echo "   base ref   : ${{ env.GITHUB_BASE_REF_SLUG_URL }}"
    echo "   event ref  : ${{ env.GITHUB_EVENT_REF_SLUG_URL }}"
    echo "   repository : ${{ env.GITHUB_REPOSITORY_SLUG_URL }}"
    echo "Short SHA variables"
    echo "   sha        : ${{ env.GITHUB_SHA_SHORT }}"
Enter fullscreen mode Exit fullscreen mode

Additional Resources / Info

Some repositories already using it like

And more on GitHub search page

GitHub logo rlespinasse / github-slug-action

GitHub Action to expose slug value of GitHub environment variables inside your GitHub workflow

Contributions welcome

Top comments (0)