@@ -22,11 +22,33 @@ jobs:
2222 - name : Check if tag is from main branch
2323 id : check-branch
2424 run : |
25- if [ "$(git branch -r --contains ${{ github.ref }})" == "origin/main" ]; then
26- echo "IS_MAIN=true" >> $GITHUB_ENV
27- else
28- echo "IS_MAIN=false" >> $GITHUB_ENV
29- fi
25+ # Get the commit that the tag points to
26+ TAG_COMMIT=$(git rev-parse ${{ github.ref }})
27+ # Get the latest commit from main branch
28+ MAIN_COMMIT=$(git rev-parse origin/main)
29+
30+ echo "Debug Information:"
31+ echo "Current tag ref : ${{ github.ref }}"
32+ echo "Tag commit hash : $TAG_COMMIT"
33+ echo "Main branch commit hash : $MAIN_COMMIT"
34+ echo "All branches containing this tag:"
35+ git branch -r --contains ${{ github.ref }}
36+
37+ # Check if the tag commit is reachable from main branch
38+ if git merge-base --is-ancestor $TAG_COMMIT $MAIN_COMMIT; then
39+ echo "✅ Tag is from main branch"
40+ echo "IS_MAIN=true" >> $GITHUB_ENV
41+ else
42+ echo "❌ Tag is not from main branch"
43+ echo "IS_MAIN=false" >> $GITHUB_ENV
44+ fi
45+
46+ # Print the final decision
47+ echo "Final IS_MAIN value : ${{ env.IS_MAIN }}"
48+
49+ # Print git history for debugging
50+ echo "Recent git history:"
51+ git log --oneline -n 5
3052
3153 - name : Configure AWS credentials
3254 if : env.IS_MAIN == 'true'
0 commit comments