|
| 1 | +name: CLA Check |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize, reopened] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +jobs: |
| 11 | + cla-check: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + name: Check CLA Status |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Check CLA Status |
| 17 | + id: cla-check |
| 18 | + run: | |
| 19 | + # Get PR author username |
| 20 | + PR_AUTHOR="${{ github.event.pull_request.user.login }}" |
| 21 | + echo "Checking CLA status for user: $PR_AUTHOR" |
| 22 | +
|
| 23 | + # Fetch the CLA list |
| 24 | + CLA_RESPONSE=$(curl -s "https://cla.science.xyz/list") |
| 25 | +
|
| 26 | + # Check if the response is valid JSON and contains the user |
| 27 | + if echo "$CLA_RESPONSE" | jq -e ".submissions[] | select(.github == \"$PR_AUTHOR\")" > /dev/null 2>&1; then |
| 28 | + echo "✅ CLA signed by $PR_AUTHOR" |
| 29 | + echo "cla_signed=true" >> $GITHUB_OUTPUT |
| 30 | + else |
| 31 | + echo "❌ CLA not signed by $PR_AUTHOR" |
| 32 | + echo "cla_signed=false" >> $GITHUB_OUTPUT |
| 33 | + fi |
| 34 | +
|
| 35 | + echo "pr_author=$PR_AUTHOR" >> $GITHUB_OUTPUT |
| 36 | +
|
| 37 | + - name: CLA Check Failed |
| 38 | + if: steps.cla-check.outputs.cla_signed == 'false' |
| 39 | + run: | |
| 40 | + echo "::error title=CLA Required::@${{ steps.cla-check.outputs.pr_author }} needs to sign the Contributor License Agreement (CLA) at https://cla.science.xyz/ before this PR can be merged." |
| 41 | + echo "" |
| 42 | + echo "Once you've signed the CLA, you can re-run this check by:" |
| 43 | + echo "- Pushing a new commit to this PR, or" |
| 44 | + echo "- Closing and reopening this PR" |
| 45 | + echo "" |
| 46 | + echo "❌ CLA not signed by ${{ steps.cla-check.outputs.pr_author }}" |
| 47 | + exit 1 |
| 48 | +
|
| 49 | + - name: CLA Check Passed |
| 50 | + if: steps.cla-check.outputs.cla_signed == 'true' |
| 51 | + run: | |
| 52 | + echo "CLA check passed for ${{ steps.cla-check.outputs.pr_author }}" |
| 53 | +
|
0 commit comments