forked from supabase/supabase
-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (73 loc) · 2.54 KB
/
auto-label-issues.yml
File metadata and controls
73 lines (73 loc) · 2.54 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Auto Label Issues
on:
issues:
types: [opened, reopened]
jobs:
check-external:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Check if organization member
id: is-org-member
uses: JamesSingleton/is-organization-member@39c59b3b17cca4eb75c81772b95e724e2a24c025 # v1.0.0
with:
organization: ${{ github.repository_owner }}
username: ${{ github.event.issue.user.login }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: label-member
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
IS_INTERNAL: ${{ steps.is-org-member.outputs.result }}
run: |
if [ "$IS_INTERNAL" != "true" ]; then
echo "User is outside of organization, labeling external"
gh issue edit "$NUMBER" --add-label "external-issue"
else
echo "User is within the organization, labeling internal"
gh issue edit "$NUMBER" --add-label "internal-issue"
fi
triage-new:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Label triage
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
LABELS: to-triage
run: |
echo "Applying triage label for new issue"
gh issue edit "$NUMBER" --add-label "$LABELS"
spam-detection:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Check GitHub Issue for spam
env:
POST_URL: ${{ secrets.POST_URL }}
BEARER_TOKEN: ${{ secrets.BEARER_TOKEN }}
NUMBER: ${{ github.event.issue.number }}
run: |
RESPONSE=$(curl -s -X POST "$POST_URL" \
-H "Authorization: Bearer $BEARER_TOKEN" \
-H "Content-Type: application/json" \
-d '{"issue_id": $NUMBER}')
echo "spam_response=$RESPONSE" >> $GITHUB_OUTPUT
- name: Use spam detector output to label issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
LABEL: flagged
run: |
IS_SPAM=$(echo "$SPAM_RESPONSE" | jq -r '.spam')
if [ "$IS_SPAM" == "true" ]; then
echo "Applying flagged label for new issue suspected of spam"
gh issue edit "$NUMBER" --add-label "$LABEL"
fi