ohcnetwork / care_fe

Care is a Digital Public Good enabling TeleICU & Decentralised Administration of Healthcare Capacity across States.
https://care.ohc.network
MIT License
245 stars 427 forks source link

Automate Labeling of Issues Based on Comments from Non-Core Members #8847

Open aravindm4 opened 2 weeks ago

aravindm4 commented 2 weeks ago

Is your feature request related to a problem? Please describe. Currently, there is no way to track issues with unresolved comments. Contributors, interns, or anyone other than core team members may have shared a comment that requires action from the core team, but it might be missed, causing the issue to stall.

Describe the solution you'd like To identify such cases, a label can be automatically added to the issue whenever someone other than a core team member comments.

Feature Requirements:

bodhish commented 2 weeks ago

@aravindm4 lets just add the tag, lets not make the removal automatic.

name: Notify Core Team on Non-Core Questions

on:
  issue_comment:
    types: [created]

jobs:
  notify_core_team:
    runs-on: ubuntu-latest
    steps:
      - name: Check if commenter is non-core member
        uses: actions/github-script@v6
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            const coreMembers = ['coreMember1', 'coreMember2']; // Define core members
            const commenter = context.payload.comment.user.login;
            if (!coreMembers.includes(commenter)) {
              return commenter; // Proceed if not core member
            }

      - name: Check if comment is a question
        id: check_question
        run: |
          echo "${{ github.event.comment.body }}" | grep -Eq "(\?|what|how|why|when|who)"

      - name: Notify core team
        if: ${{ steps.check_question.outcome == 'success' }}
        run: |
          curl -X POST -H 'Content-type: application/json' --data '{"text":"A non-core member posted a question: https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }}"}' ${{ secrets.SLACK_WEBHOOK }}

      - name: Add question label (optional)
        if: ${{ steps.check_question.outcome == 'success' }}
        uses: actions/github-script@v6
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          script: |
            await github.issues.addLabels({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.payload.issue.number,
              labels: ['question'],
            });

Something like this with options for questions and core configurable via actions env