Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
45 lines (41 loc) · 1.39 KB
/
Copy pathaction.yml
File metadata and controls
45 lines (41 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
name: Commit Hash Verifier
description: Verifies the validity of a commit hash from a specific branch
author: shiftEscape
branding:
icon: "git-commit"
color: "purple"
inputs:
commit-hash:
description: "The commit hash to verify"
required: true
default: ${{ github.sha }}
branch-name:
description: "The name of the branch to check the commit against"
required: true
default: ${{ github.ref }}
outputs:
valid_commit:
description: "Indicates if the commit hash is valid"
value: ${{ steps.verify-commit.outputs.valid_commit }}
runs:
using: "composite"
steps:
- name: Verify commit hash
id: verify-commit
shell: bash
run: |
branch_name="${{ inputs.branch-name }}"
commit_id="${{ inputs.commit-hash }}"
if ! git rev-parse --quiet --verify "${commit_id}"; then
echo "valid_commit=false" >> $GITHUB_OUTPUT
echo "Invalid commit hash: \`$commit_id\`"
else
# Verify if the commit is on the specified branch
if ! git merge-base --is-ancestor "${commit_id}" "${branch_name}"; then
echo "valid_commit=false" >> $GITHUB_OUTPUT
echo "Commit \`$commit_id\` not found on the branch \`$branch_name\`"
else
echo "valid_commit=true" >> $GITHUB_OUTPUT
echo "Commit \`$commit_id\` is valid on the branch \`$branch_name\`"
fi
fi