DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Romain Lespinasse
Romain Lespinasse

Posted on • Updated 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)

Timeless DEV post...

How to write a kickass README

Arguably the single most important piece of documentation for any open source project is the README. A good README not only informs people what the project does and who it is for but also how they use and contribute to it.

If you write a README without sufficient explanation of what your project does or how people can use it then it pretty much defeats the purpose of being open source as other developers are less likely to engage with or contribute towards it.