Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/auto-reply.yml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To prevent repeated comments if users comment multiple times, you can
Check existing bot comments before replying.
If someone comments twice with “assign” or similar, the bot will comment each time. This creates noise.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Auto-reply to Assign Requests

on:
issue_comment:
types: [created]

jobs:
auto-reply:
runs-on: ubuntu-latest
if: github.event.issue.pull_request == null
env:
KEYWORDS: "assign,work on this,take this up,pick this,want this"
RESPONSE_MESSAGE: "Please go ahead and create a PR when you are ready. We do not formally assign issues. Contributors are free to pick up any open issue based on their availability. You can open a PR or even a draft PR to let others know that you're working on it."
steps:
- name: Auto reply if assign keyword is used
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const commentBody = context.payload.comment.body;
const commenter = context.payload.comment.user.login;
const issueNumber = context.payload.issue.number;
const owner = context.repo.owner;
const repo = context.repo.repo;

const keywords = process.env.KEYWORDS.split(',').map(k => k.trim());
const responseMessage = `@${commenter} ${process.env.RESPONSE_MESSAGE}`;

const matched = keywords.some(keyword => {
const escapedKeyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const regex = new RegExp(`\\b${escapedKeyword}\\b`, 'i');
return regex.test(commentBody);
});

if (!matched) return;

const comments = await github.rest.issues.listComments({
owner,
repo,
issue_number: issueNumber
});

const alreadyReplied = comments.data.some(c =>
c.user.type === 'Bot' && c.body.includes(`@${commenter}`)
);

if (alreadyReplied) return;

await github.rest.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body: responseMessage
});
Loading