Skip to content

A Github Action to Export env and output sha with a shortened commit SHA

License

Notifications You must be signed in to change notification settings

soc221b/shorten-commit-sha

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Shorten Commit SHA

Export env and output sha with the shortened commit SHA.

Example Usage

jobs:
  job1:
    runs-on: ubuntu-latest
    name: Job 1
    steps:
      - uses: actions/[email protected]
        with:
          fetch-depth: 0

      - id: shorten_commit_sha
        uses: iendeavor/[email protected]

      - run: |
          echo "env: ${{ env.shortened_commit_sha }}"
          echo "output: ${{ steps.shorten_commit_sha.outputs.shortened_commit_sha }}"

  job2:
    runs-on: ubuntu-latest
    name: Job 2
    steps:
      - uses: actions/[email protected]
        with:
          fetch-depth: 0

      - id: shorten_commit_sha
        uses: iendeavor/[email protected]
        with:
          env_name: foo
          length: 8
          output_name: bar
          pull_request_github_sha: github.event.pull_request.head.sha # use the last commit to the head branch of the pull request, instead of the last merge commit of the pull request merge branch

      - run: |
          echo "env: ${{ env.foo }}"
          echo "output: ${{ steps.shorten_commit_sha.outputs.bar }}"

Input

See action.yml

Name Default Options Description
env_name 'shortened_commit_sha' The env name of the shortened sha.
length '7' The length of the shortened sha.
output_name 'shortened_commit_sha' The output name of the shortened sha.
pull_request_github_sha "github.sha" "github.sha" | "github.event.pull_request.head.sha" The sha to be shortened for pull requests. See also: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request

Sponsor

Thank you for using shorten-commit-sha action.

If this helps you, please consider by me a coffee: