Skip to content

Refactor issue acknowledgment workflow #2

Refactor issue acknowledgment workflow

Refactor issue acknowledgment workflow #2

name: Auto Acknowledge GH Issues

Check failure on line 1 in .github/workflows/issue-acknowledge.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/issue-acknowledge.yml

Invalid workflow file

(Line: 9, Col: 3): 'issues' is already defined
on:
issues:
types: [opened]
permissions:
issues: read
issues: write
jobs:
acknowledge:
runs-on: ubuntu-latest
permissions:
issues: read
steps:
- name: Wait 15 minutes
run: sleep 30
- name: Check for existing maintainer response
id: check
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const maintainers = ['sumitmsft'];
const issueNumber = context.payload.inputs?.issue_number
? parseInt(context.payload.inputs.issue_number)
: context.payload.issue.number;
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber
});
const maintainerReplied = comments.data.some(
comment => maintainers.includes(comment.user.login)
);
core.setOutput('skip', maintainerReplied.toString());
core.setOutput('issue_number', issueNumber.toString());
console.log(`Maintainer already replied: ${maintainerReplied}`);
# Generate a short-lived token from the GitHub App
- name: Generate App Token
if: steps.check.outputs.skip == 'false'
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Post acknowledgement comment
if: steps.check.outputs.skip == 'false'
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const issueNumber = parseInt('${{ steps.check.outputs.issue_number }}');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
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!`
});