Skip to content

Commit d5c5042

Browse files
authored
Refactor issue acknowledgment workflow
Updated issue acknowledgment workflow to improve token handling and response logic.
1 parent f4504e0 commit d5c5042

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

.github/workflows/issue-acknowledge.yml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,64 @@ on:
55
types: [opened]
66

77
permissions:
8-
contents: read
8+
issues: read
99
issues: write
10+
1011
jobs:
1112
acknowledge:
1213
runs-on: ubuntu-latest
1314
permissions:
1415
issues: read
1516
steps:
16-
# Step 1: Wait 15 minutes
1717
- name: Wait 15 minutes
18-
run: sleep 10
18+
run: sleep 30
1919

20-
# Step 2: Check if a maintainer already responded
2120
- name: Check for existing maintainer response
2221
id: check
2322
uses: actions/github-script@v7
2423
with:
2524
github-token: ${{ secrets.GITHUB_TOKEN }}
2625
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;
2831
2932
const comments = await github.rest.issues.listComments({
3033
owner: context.repo.owner,
3134
repo: context.repo.repo,
32-
issue_number: context.payload.issue.number
35+
issue_number: issueNumber
3336
});
3437
3538
const maintainerReplied = comments.data.some(
3639
comment => maintainers.includes(comment.user.login)
3740
);
3841
3942
core.setOutput('skip', maintainerReplied.toString());
43+
core.setOutput('issue_number', issueNumber.toString());
4044
console.log(`Maintainer already replied: ${maintainerReplied}`);
4145
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+
4355
- name: Post acknowledgement comment
4456
if: steps.check.outputs.skip == 'false'
4557
uses: actions/github-script@v7
4658
with:
47-
github-token: ${{ secrets.SUMIT_PAT_FOR_AUTO_RESPONSE }}
59+
github-token: ${{ steps.app-token.outputs.token }}
4860
script: |
61+
const issueNumber = parseInt('${{ steps.check.outputs.issue_number }}');
62+
4963
await github.rest.issues.createComment({
5064
owner: context.repo.owner,
5165
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!`
5468
});

0 commit comments

Comments
 (0)