Skip to content

Commit 0eeacb5

Browse files
committed
Refactor CLA workflow to use base SHA for accurate comparison
1 parent 8e563d5 commit 0eeacb5

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

.github/workflows/cla-check.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,18 @@ jobs:
6767
echo "🔴 CONTRIBUTORS.md file does not exist on PR branch."
6868
fi
6969
70-
# --- Check if CONTRIBUTORS.md was modified in this PR ---
70+
# -- Check if CONTRIBUTORS.md was modified in this PR
7171
- name: Check if CONTRIBUTORS.md was modified in PR
7272
id: check_contributors_modified
7373
run: |
74-
# Get the list of changed files in the PR
74+
# Fetch the base branch
7575
git fetch origin ${{ github.event.pull_request.base.ref }}
76-
CHANGED_FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD)
76+
77+
# Use the base SHA directly for comparison (works with forks)
78+
BASE_SHA="${{ github.event.pull_request.base.sha }}"
79+
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
80+
81+
CHANGED_FILES=$(git diff --name-only $BASE_SHA..$HEAD_SHA)
7782
7883
if echo "$CHANGED_FILES" | grep -q "^CONTRIBUTORS.md$"; then
7984
echo "modified=true" >> $GITHUB_OUTPUT
@@ -83,7 +88,7 @@ jobs:
8388
echo "ℹ️ CONTRIBUTORS.md file was NOT modified in this PR."
8489
fi
8590
86-
# --- Step 3: Manage PR Labels, Comments, and Final Status (Consolidated) ---
91+
# -- Step 3: Manage PR Labels, Comments, and Final Status (Consolidated)
8792
- name: Manage CLA Status, Labels, and Comments
8893
uses: actions/github-script@v8
8994
# Using 'always()' here so this step runs regardless of previous

0 commit comments

Comments
 (0)