|
5 | 5 | types: [opened] |
6 | 6 |
|
7 | 7 | permissions: |
8 | | - contents: read |
| 8 | + issues: read |
9 | 9 | issues: write |
| 10 | + |
10 | 11 | jobs: |
11 | 12 | acknowledge: |
12 | 13 | runs-on: ubuntu-latest |
13 | 14 | permissions: |
14 | 15 | issues: read |
15 | 16 | steps: |
16 | | - # Step 1: Wait 15 minutes |
17 | 17 | - name: Wait 15 minutes |
18 | | - run: sleep 10 |
| 18 | + run: sleep 30 |
19 | 19 |
|
20 | | - # Step 2: Check if a maintainer already responded |
21 | 20 | - name: Check for existing maintainer response |
22 | 21 | id: check |
23 | 22 | uses: actions/github-script@v7 |
24 | 23 | with: |
25 | 24 | github-token: ${{ secrets.GITHUB_TOKEN }} |
26 | 25 | script: | |
27 | | - const maintainers = ['sumitmsft','dlevy-msft-sql']; |
| 26 | + const maintainers = ['sumitmsft']; |
| 27 | +
|
| 28 | + const issueNumber = context.payload.inputs?.issue_number |
| 29 | + ? parseInt(context.payload.inputs.issue_number) |
| 30 | + : context.payload.issue.number; |
28 | 31 |
|
29 | 32 | const comments = await github.rest.issues.listComments({ |
30 | 33 | owner: context.repo.owner, |
31 | 34 | repo: context.repo.repo, |
32 | | - issue_number: context.payload.issue.number |
| 35 | + issue_number: issueNumber |
33 | 36 | }); |
34 | 37 |
|
35 | 38 | const maintainerReplied = comments.data.some( |
36 | 39 | comment => maintainers.includes(comment.user.login) |
37 | 40 | ); |
38 | 41 |
|
39 | 42 | core.setOutput('skip', maintainerReplied.toString()); |
| 43 | + core.setOutput('issue_number', issueNumber.toString()); |
40 | 44 | console.log(`Maintainer already replied: ${maintainerReplied}`); |
41 | 45 |
|
42 | | - # Step 3: Post acknowledgement ONLY if no maintainer has responded |
| 46 | + # Generate a short-lived token from the GitHub App |
| 47 | + - name: Generate App Token |
| 48 | + if: steps.check.outputs.skip == 'false' |
| 49 | + id: app-token |
| 50 | + uses: actions/create-github-app-token@v1 |
| 51 | + with: |
| 52 | + app-id: ${{ secrets.APP_ID }} |
| 53 | + private-key: ${{ secrets.APP_PRIVATE_KEY }} |
| 54 | + |
43 | 55 | - name: Post acknowledgement comment |
44 | 56 | if: steps.check.outputs.skip == 'false' |
45 | 57 | uses: actions/github-script@v7 |
46 | 58 | with: |
47 | | - github-token: ${{ secrets.SUMIT_PAT_FOR_AUTO_RESPONSE }} |
| 59 | + github-token: ${{ steps.app-token.outputs.token }} |
48 | 60 | script: | |
| 61 | + const issueNumber = parseInt('${{ steps.check.outputs.issue_number }}'); |
| 62 | +
|
49 | 63 | await github.rest.issues.createComment({ |
50 | 64 | owner: context.repo.owner, |
51 | 65 | repo: context.repo.repo, |
52 | | - issue_number: context.payload.issue.number, |
53 | | - body: `Hi @${context.payload.issue.user.login}, thank you for opening this issue!\n\nOur team will review it shortly. We aim to triage all new issues within 24-48 hours and get back to you.\n\nThank you for your patience!` |
| 66 | + issue_number: issueNumber, |
| 67 | + body: `Hi @${context.payload.issue?.user?.login || 'there'}, thank you for opening this issue!\n\nOur team will review it shortly. We aim to triage all new issues within 24-48 hours.\n\nThank you for your patience!` |
54 | 68 | }); |
0 commit comments