Created
June 26, 2024 14:21
-
-
Save zachelrath/8046465d61be9048c694f3560b8d2c91 to your computer and use it in GitHub Desktop.
Require tag's commit to have been built off of main branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get the current commit SHA | |
current_commit_sha=$(git rev-parse HEAD) | |
# Get the SHA of the "origin/main" branch | |
origin_main_sha=$(git rev-parse origin/main) | |
# Check if the current commit SHA matches the "origin/main" SHA or any parent commit SHA | |
if git merge-base --is-ancestor $current_commit_sha $origin_main_sha; then | |
echo "Commit is on the main branch" | |
else | |
echo "Commit not found on main branch" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment