DEV Community

Romain Lespinasse
Romain Lespinasse

Posted on • Edited on

1 1

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

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay