needs-response.yml

 1name: "Needs Response"
 2
 3on:
 4  issue_comment:
 5    types: [created]
 6
 7permissions:
 8  issues: write
 9
10jobs:
11  toggle-label:
12    if: github.event.issue.pull_request == null
13    runs-on: ubuntu-latest
14    steps:
15      - name: Add needs-response when maintainer comments
16        if: >
17          contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.comment.author_association) &&
18          github.event.comment.user.login != github.event.issue.user.login
19        uses: actions/github-script@v9
20        with:
21          github-token: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}
22          script: |
23            await github.rest.issues.addLabels({
24              owner: context.repo.owner,
25              repo: context.repo.repo,
26              issue_number: context.payload.issue.number,
27              labels: ['needs-response']
28            });
29
30      - name: Remove needs-response when issue author replies
31        if: github.event.comment.user.login == github.event.issue.user.login
32        uses: actions/github-script@v9
33        with:
34          github-token: ${{ secrets.HOMEBREW_GITHUB_TOKEN }}
35          script: |
36            try {
37              await github.rest.issues.removeLabel({
38                owner: context.repo.owner,
39                repo: context.repo.repo,
40                issue_number: context.payload.issue.number,
41                name: 'needs-response'
42              });
43            } catch (e) {
44              if (e.status !== 404) throw e;
45            }