Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions .github/workflows/cla-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,42 @@ jobs:
exit 0
fi

echo "Committers on PR: $(echo $COMMITTERS | tr '\n' ' ')"
TOTAL=$(echo "$COMMITTERS" | wc -l)
echo "Committers on PR ($TOTAL): $(echo $COMMITTERS | tr '\n' ' ')"

EXEMPT=""
EXEMPT_COUNT=0

# Non-fork PRs: all committers have push access
if [[ "$HEAD" == "$BASE_REPO" ]]; then
echo "Non-fork PR - all committers exempt from CLA"
EXEMPT=$(echo "$COMMITTERS" | paste -sd,)
EXEMPT_COUNT=$TOTAL
else
# Fork PRs: check each committer's permission
while IFS= read -r user; do
[[ -z "$user" ]] && continue
PERM=$(gh api "repos/$BASE_REPO/collaborators/$user/permission" --jq '.permission' 2>/dev/null || echo "none")
if [[ "$PERM" == "admin" || "$PERM" == "maintain" || "$PERM" == "write" ]]; then
echo "$user: CLA not needed (exempt)"
echo "$user: exempt"
EXEMPT="${EXEMPT:+$EXEMPT,}$user"
EXEMPT_COUNT=$((EXEMPT_COUNT + 1))
else
echo "$user: CLA needed"
fi
done <<< "$COMMITTERS"
fi

if [[ "$EXEMPT_COUNT" -eq "$TOTAL" ]]; then
echo "All committers exempt - CLA check not needed"
echo "cla-needed=false" >> $GITHUB_OUTPUT
else
echo "cla-needed=true" >> $GITHUB_OUTPUT
fi

if [[ -n "$EXEMPT" ]]; then
echo "Exempt users: $EXEMPT"
echo "allowlist=$BASE_ALLOWLIST,$EXEMPT" >> $GITHUB_OUTPUT
else
echo "No exempt users found"
echo "allowlist=$BASE_ALLOWLIST" >> $GITHUB_OUTPUT
fi
env:
Expand All @@ -89,9 +98,10 @@ jobs:
- name: Generate GitHub App Token
id: app-token
if: >-
contains(github.event.comment.body, 'recheck') ||
steps.check-perms.outputs.cla-needed != 'false' &&
(contains(github.event.comment.body, 'recheck') ||
github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA' ||
github.event_name == 'pull_request_target'
github.event_name == 'pull_request_target')
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.CLA_APP_ID }}
Expand All @@ -101,9 +111,10 @@ jobs:

- name: "CLA Assistant"
if: >-
contains(github.event.comment.body, 'recheck') ||
steps.check-perms.outputs.cla-needed != 'false' &&
(contains(github.event.comment.body, 'recheck') ||
github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA' ||
github.event_name == 'pull_request_target'
github.event_name == 'pull_request_target')
uses: contributor-assistant/github-action@v2.6.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down