1name: Issue Subscriber
2
3on:
4  issues:
5    types:
6      - labeled
7
8jobs:
9  auto-subscribe:
10    runs-on: ubuntu-latest
11    if: github.repository == 'llvm/llvm-project'
12    steps:
13    - name: Update watchers
14      uses: actions/github-script@v5
15      with:
16        github-token: ${{ secrets.ISSUE_MENTION_SECRET }}
17        script: |
18            const teamname = "issue-subscribers-" + context.payload.label.name.replace(/ /g, "-").replace(":","-").replace("/","-");
19            const comment = "@llvm/" + teamname;
20            try {
21              // This will throw an exception if the team does not exist and no
22              // comment will be created.
23              team = await github.rest.teams.getByName({
24                org: context.repo.owner,
25                team_slug: teamname
26              });
27              github.rest.issues.createComment({
28                issue_number: context.issue.number,
29                owner: context.repo.owner,
30                repo: context.repo.repo,
31                body: comment
32              });
33            } catch (e){
34              console.log(e);
35            }
36