Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate PR Flagging and Notifications #6961

Open
JuanPabloDiaz opened this issue Jul 4, 2024 · 0 comments
Open

Automate PR Flagging and Notifications #6961

JuanPabloDiaz opened this issue Jul 4, 2024 · 0 comments
Labels
github_actions Pull requests that update GitHub Actions code

Comments

@JuanPabloDiaz
Copy link
Collaborator

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

  • The workflow will trigger on the following pull request events: opened, edited, reopened.

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 }}
@JuanPabloDiaz JuanPabloDiaz added the github_actions Pull requests that update GitHub Actions code label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github_actions Pull requests that update GitHub Actions code
Projects
None yet
Development

No branches or pull requests

1 participant