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

Add GitHub Action to auto-close PRs with style tags #3827

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

vidipsingh
Copy link
Contributor

@vidipsingh vidipsingh commented Mar 5, 2025

User description

Fixes: #3825


PR Type

Enhancement, Configuration changes


Description

  • Added a GitHub Action to automatically close PRs with style-related labels.

  • Configured the workflow to trigger on PR label addition events.

  • Implemented logic to detect specific style-related labels like style, css, and formatting.

  • Automated PR closure with a comment explaining the reason.


Changes walkthrough 📝

Relevant files
Configuration changes
close-style-prs.yml
Added GitHub Action to close PRs with style tags                 

.github/workflows/close-style-prs.yml

  • Created a new GitHub Action workflow file.
  • Added logic to detect style-related labels on PRs.
  • Configured the workflow to close PRs with a comment if such labels are
    detected.
  • Included permissions and environment variable setup for GitHub CLI.
  • +31/-0   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    github-actions bot commented Mar 5, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis 🔶

    3825 - Partially compliant

    Compliant requirements:

    • Create a GitHub Action that automatically closes PRs containing <style> tags.
    • Configure the workflow to trigger on PR label addition events.
    • Detect specific style-related labels like style, css, and formatting.
    • Automatically close PRs with a comment explaining the reason.

    Non-compliant requirements:

    []

    Requires further human verification:

    []

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Possible Logic Duplication

    The condition to check for style-related labels is repeated in both steps (lines 20-21 and 26-27). Consider refactoring to avoid duplication and improve maintainability.

      if: |
        contains(fromJSON('["style", "css", "formatting"]'), github.event.label.name)
      run: echo "Style label detected: ${{ github.event.label.name }}"
    
    # Step 2: Close the Pull Request if it has a style label
    - name: Close Pull Request
      if: |
        contains(fromJSON('["style", "css", "formatting"]'), github.event.label.name)

    Copy link
    Contributor

    github-actions bot commented Mar 5, 2025

    PR Code Suggestions ✨

    Copy link
    Collaborator

    @DonnieBLT DonnieBLT left a comment

    Choose a reason for hiding this comment

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

    Correct approach but we don’t want to check labels, we want to check code staged for merge. Sort of like the precommit

    @vidipsingh
    Copy link
    Contributor Author

    Correct approach but we don’t want to check labels, we want to check code staged for merge. Sort of like the precommit

    @DonnieBLT Ok, I will look into it and make the necessary changes.

    @vidipsingh vidipsingh requested a review from DonnieBLT March 7, 2025 20:17
    @vidipsingh
    Copy link
    Contributor Author

    Hi @DonnieBLT, Could you please review my changes and let me know if there's anything else I should modify?

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    Create a GitHub action that will automatically close PRS that have any style tags in them
    2 participants