1name: "Label new and reopened blank issues for triage"
2
3on:
4 issues:
5 types:
6 - opened
7 - reopened
8
9permissions:
10 contents: read
11
12jobs:
13 add-triage-label:
14 if: github.repository == 'zed-industries/zed'
15 runs-on: namespace-profile-2x4-ubuntu-2404
16 timeout-minutes: 5
17 steps:
18 - id: get-app-token
19 uses: actions/create-github-app-token@bef1eaf1c0ac2b148ee2a0a74c65fbe6db0631f1 # v2.1.4
20 with:
21 app-id: ${{ secrets.ZED_COMMUNITY_BOT_APP_ID }}
22 private-key: ${{ secrets.ZED_COMMUNITY_BOT_PRIVATE_KEY }}
23 owner: zed-industries
24
25 - id: check-staff
26 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
27 with:
28 github-token: ${{ steps.get-app-token.outputs.token }}
29 script: |
30 try {
31 const response = await github.rest.teams.getMembershipForUserInOrg({
32 org: 'zed-industries',
33 team_slug: 'staff',
34 username: context.payload.sender.login
35 });
36 return response.data.state === 'active';
37 } catch (error) {
38 if (error.status === 404) {
39 return false;
40 }
41 throw error;
42 }
43
44 - if: steps.check-staff.outputs.result == 'true'
45 env:
46 ISSUE_NUMBER: ${{ github.event.issue.number }}
47 run: |
48 echo "::notice::Skipping issue #$ISSUE_NUMBER - actor is staff member"
49
50 - if: steps.check-staff.outputs.result == 'false'
51 id: add-label
52 uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
53 with:
54 github-token: ${{ steps.get-app-token.outputs.token }}
55 script: |
56 const issue = context.payload.issue;
57 const hasTriageLabel = issue.labels.some(
58 label => label.name === 'state:needs triage'
59 );
60
61 if (hasTriageLabel) {
62 console.log('Issue already has state:needs triage, skipping');
63 return;
64 }
65
66 await github.rest.issues.addLabels({
67 owner: context.repo.owner,
68 repo: context.repo.repo,
69 issue_number: issue.number,
70 labels: ['state:needs triage']
71 });
72
73 console.log(`Added state:needs triage to issue #${issue.number}`);