eltimn / slugify-action

Slugify branch name and shorten commit SHA
MIT License
0 stars 1 forks source link

Slugify Github Action

This action slugifies the commit ref (branch or tag name) similar to what Gitlab uses. It also sets a shortened commit SHA.

Slugify will get the branch name for push and pull_request events and then process it as follows:

inputs

sha_length:

outputs:

branch:

Usage

Define a workflow in .github/workflows/continuous-integration.yml (or add a job if you already have defined workflows).

:bulb: Read more about Configuring a workflow.

on:
  pull_request:
  push:
    branches:
      - main
    tags:
      - "**"

name: "Continuous Integration"

jobs:
  github-action-template:
    name: github-action-template

    runs-on: ubuntu-latest

    steps:
      - name: "Checkout"
        uses: actions/checkout@v3

      - name: "Run slugify"
        id: slugify
        uses: eltimn/slugify-action@v2

      - name: "Echo slugify outputs"
        run: |
          echo ${{steps.slugify.outputs.branch}}-${{steps.slugify.outputs.sha}}

License

This package is licensed using the MIT

Publishing

Run npm run package to create a distribution artifact.