tech-conferences / conference-data

Conference data for www.confs.tech
https://confs.tech
MIT License
261 stars 168 forks source link

Automate PR Flagging and Notifications #6961

Open JuanPabloDiaz opened 2 weeks ago

JuanPabloDiaz commented 2 weeks ago

It will be a great idea to add a workflow that checks the PRs

GitHub Actions workflow that automates the review process for pull requests (PRs) in our repository. The workflow will:

  1. Check the PRs to determine if they are dev related or not. (based on some keyword or some parameters)
  2. Automatically label the PRs as dev-related or non-dev-related.
  3. Notify the maintainers when a dev-related PR is submitted for prompt review.
  4. Sent/suggest a message if they are not dev related.

Workflow Details

Trigger

Steps

  1. Checkout Code: Use actions/checkout@v2 to check out the repository code.
  2. Keyword Check: Run a script to check the PR title and description for specific dev-related keywords (e.g., dev, developer, frontend, backend, fullstack, programming, code).
  3. Add Label: Use actions-ecosystem/action-add-labels@v1 to add a label (dev-related or non-dev-related) based on the keyword check result.
  4. Notify Maintainers: If the PR is dev-related, send a notification comment to the PR to inform the maintainers for prompt review.

Example Workflow Configuration


name: PR Check

on:
  pull_request:
    types: [opened, edited, reopened]

jobs:
  check-pr:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout code
      uses: actions/checkout@v2

    - name: Check for dev-related keywords
      id: keyword-check
      run: |
        keywords="dev,developer,frontend,backend,fullstack,programming,code"
        if echo "${{ github.event.pull_request.title }} ${{ github.event.pull_request.body }}" | grep -iE "$keywords"; then
          echo "::set-output name=is-dev-related::true"
        else
          echo "::set-output name=is-dev-related::false"
        fi

    - name: Add label based on keyword check
      uses: actions-ecosystem/action-add-labels@v1
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        labels: ${{ steps.keyword-check.outputs.is-dev-related == 'true' && 'dev-related' || 'non-dev-related' }}

    - name: Notify maintainers
      if: steps.keyword-check.outputs.is-dev-related == 'true'
      run: |
        curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
        -d '{"body": "A new dev-related PR has been submitted. Please review it at your earliest convenience."}' \
        https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}