forked from koala73/worldmonitor
-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (44 loc) · 1.85 KB
/
contributor-trust.yml
File metadata and controls
47 lines (44 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
name: Contributor Trust
on:
pull_request_target:
types: [opened, reopened]
jobs:
check:
# Skip for repo members/owners/collaborators
if: |
github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' ||
github.event.pull_request.author_association == 'FIRST_TIMER' ||
github.event.pull_request.author_association == 'CONTRIBUTOR' ||
github.event.pull_request.author_association == 'NONE'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Check contributor trust
id: brin
run: |
AUTHOR="${{ github.event.pull_request.user.login }}"
RESPONSE=$(curl -sf --max-time 10 "https://api.brin.sh/contributor/${AUTHOR}" 2>/dev/null || true)
if [ -z "$RESPONSE" ]; then
echo "verdict=unavailable" >> "$GITHUB_OUTPUT"
else
VERDICT=$(echo "$RESPONSE" | python3 -c "import sys,json; d=json.load(sys.stdin); v=d.get('verdict',''); print(v if v in ('safe','caution','suspicious','dangerous') else 'unavailable')" 2>/dev/null || echo "unavailable")
echo "verdict=$VERDICT" >> "$GITHUB_OUTPUT"
fi
- name: Apply trust label
if: |
steps.brin.outputs.verdict == 'safe' ||
steps.brin.outputs.verdict == 'caution' ||
steps.brin.outputs.verdict == 'suspicious' ||
steps.brin.outputs.verdict == 'dangerous'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
env:
BRIN_VERDICT: ${{ steps.brin.outputs.verdict }}
with:
script: |
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: [`trust:${process.env.BRIN_VERDICT}`],
});