-
Notifications
You must be signed in to change notification settings - Fork 8
85 lines (79 loc) · 2.97 KB
/
Copy pathtriage-label-incoming.yml
File metadata and controls
85 lines (79 loc) · 2.97 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
74
75
76
77
78
79
80
81
82
83
84
85
name: 'Triage: Label incoming issues'
# Expected triggers: issues: [opened, reopened, unlabeled]
on:
workflow_call:
inputs:
triage_label:
description: 'Label to add to new and reopened issues'
type: string
required: false
default: 'needs-triage'
more_info_label:
description: 'Label that indicates more info is needed'
type: string
required: false
default: 'more-info-needed'
exclude_repo_admins:
description: 'Skip labeling issues opened by repo admins'
type: boolean
required: false
default: false
permissions:
issues: write
jobs:
label_incoming_issues:
runs-on: ubuntu-latest
if: github.event.action == 'opened' || github.event.action == 'reopened'
steps:
- name: Check author repo permission
if: inputs.exclude_repo_admins
id: permission
run: |
PERM=$(gh api "repos/${{ github.repository }}/collaborators/$USER/permission" --jq '.permission' 2>/dev/null) || PERM=""
echo "permission=$PERM" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: ${{ github.event.issue.user.login }}
- name: Add triage label
if: steps.permission.outputs.permission != 'admin'
run: gh issue edit "$NUMBER" --add-label "$LABELS"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
LABELS: ${{ inputs.triage_label || 'needs-triage' }}
label_more_info_issues:
runs-on: ubuntu-latest
if: github.event.action == 'unlabeled'
steps:
- name: Check if more-info-needed was removed
id: check
env:
MORE_INFO_LABEL: ${{ inputs.more_info_label || 'more-info-needed' }}
REMOVED_LABEL: ${{ github.event.label.name }}
run: |
if [ "$REMOVED_LABEL" = "$MORE_INFO_LABEL" ]; then
echo "should_label=true" >> $GITHUB_OUTPUT
else
echo "should_label=false" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Check author repo permission
if: steps.check.outputs.should_label == 'true' && inputs.exclude_repo_admins
id: permission
run: |
PERM=$(gh api "repos/${{ github.repository }}/collaborators/$USER/permission" --jq '.permission' 2>/dev/null) || PERM=""
echo "permission=$PERM" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
USER: ${{ github.event.issue.user.login }}
- name: Add triage label
if: |
steps.check.outputs.should_label == 'true' &&
steps.permission.outputs.permission != 'admin'
run: gh issue edit "$NUMBER" --add-label "$LABELS"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ github.event.issue.number }}
LABELS: ${{ inputs.triage_label || 'needs-triage' }}