Skip to content

shiftEscape/commit-hash-verifier-action

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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Commit Hash Verifier Action

Build Status License Issues Stars

Verifies the validity of a commit hash from a specific branch!

Usage

To use this action in your workflow, you can include the following step or reference your custom inputs from there.

steps:
  - name: Verify Commit
    uses: shiftEscape/commit-hash-verifier-action@<version>
    with:
      commit-hash: ${{ github.sha }} # defaults to HEAD
      branch-name: ${{ github.ref }} # defaults to current branch (triggered by event)

Inputs

  • commit-hash (required): The commit hash to verify.
  • branch-name (required): The name of the branch to check the commit against.

Outputs

  • valid-commit: Indicates if the commit hash is valid.

Example

Here's an example of a workflow that uses the Commit Hash Verifier Action:

name: Commit Validation Workflow

on:
  push:
    branches:
      - main

jobs:
  verify-commit-job:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Verify Commit Hash
        uses: shiftEscape/commit-hash-verifier-action@main # specify version using `@`
        with:
          commit-hash: ${{ github.sha }} # reference your commit hash here
          branch-name: ${{ github.ref }} # reference you branch name here

      # Exit on invalid commit hash
      - name: Stop job if commit is invalid
        if: steps.verify-commit.outputs.valid-commit == 'false'
        run: exit 1

      # Continue with other steps if commit is valid
      - name: Continue with remaining steps
        if: steps.verify-commit.outputs.valid-commit == 'true'
        run: |
          # Continue with your desired workflow logic here
          echo "Commit hash is valid and from the correct branch"