Actions Hackathon | Use Slug variables for your release and deployment workflows

This post is link to a submission on Dev.to Github Action Hackathon This post have been published first on dev.to.

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

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 }}"    

Additional Resources / Info

Some repositories already using it like

And more on GitHub search page

Contributions welcome.