add_commented_closed_issue_to_project.yml

 1name: "Surface closed issues someone's commented on"
 2
 3on:
 4  issue_comment:
 5    types:
 6      - created
 7
 8jobs:
 9  add-to-project:
10    if: >
11      github.repository == 'zed-industries/zed' &&
12      github.event.issue.state == 'closed' &&
13      github.event.issue.type.name == 'Bug' &&
14      github.event.comment.user.type != 'Bot'
15    runs-on: ubuntu-latest
16    steps:
17      - id: get-app-token
18        uses: actions/create-github-app-token@df432ccc7b4c53164ccb55b2c30ff6705e2ffc81 # v1.11.7
19        with:
20          app-id: ${{ secrets.ZED_COMMUNITY_BOT_APP_ID }}
21          private-key: ${{ secrets.ZED_COMMUNITY_BOT_PRIVATE_KEY }}
22          owner: zed-industries
23
24      - id: check-staff
25        uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
26        with:
27          github-token: ${{ steps.get-app-token.outputs.token }}
28          script: |
29            try {
30              const response = await github.rest.teams.getMembershipForUserInOrg({
31                org: 'zed-industries',
32                team_slug: 'staff',
33                username: context.payload.comment.user.login
34              });
35              return response.data.state === 'active';
36            } catch (error) {
37              // 404 means user is not a member
38              if (error.status === 404) {
39                return false;
40              }
41              throw error;
42            }
43
44      # Add to the support team's board for triage
45      - if: steps.check-staff.outputs.result == 'false'
46        uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
47        with:
48          project-url: https://github.com/orgs/zed-industries/projects/71
49          github-token: ${{ steps.get-app-token.outputs.token }}