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

Auto assign PR author #490

Merged
merged 2 commits into from
Nov 15, 2024
Merged

Auto assign PR author #490

merged 2 commits into from
Nov 15, 2024

Conversation

beastawakens
Copy link
Contributor

Trying out some logic to skip running this at all if someone is already assigned... Hard to test if this works without merging it and opening a new PR! 😆

@beastawakens beastawakens requested a review from a team as a code owner November 15, 2024 14:20
@beastawakens beastawakens self-assigned this Nov 15, 2024
@prfectionist
Copy link

prfectionist bot commented Nov 15, 2024

Title

Auto assign PR author


User description

Trying out some logic to skip running this at all if someone is already assigned... Hard to test if this works without merging it and opening a new PR! 😆


PR Type

Enhancement


Description

  • Added new GitHub Actions workflow to automatically assign PR authors as assignees
  • Workflow triggers on pull request open and reopen events
  • Includes permission configuration for pull-requests write access
  • Added logic to skip assignment if PR already has assignees
  • Uses toshimaru/[email protected] action

Changes walkthrough 📝

Relevant files
Enhancement
auto-author-assign.yml
New workflow for automatic PR author assignment                   

.github/workflows/auto-author-assign.yml

  • Added new GitHub workflow to automatically assign PR author as
    assignee
  • Configured to run on PR open/reopen events with pull-requests write
    permission
  • Added condition to skip if PR already has assignees
  • +16/-0   

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    @prfectionist
    Copy link

    prfectionist bot commented Nov 15, 2024

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 Security concerns

    Pull Request Target:
    The workflow uses 'pull_request_target' trigger which runs with repository token and access to secrets. While this is needed for PR write permissions, it could be dangerous if combined with code checkout/execution since it runs in the context of the base repository.

    ⚡ Recommended focus areas for review

    Logic Error
    The condition to check if assignees exist appears incorrect. The current check for empty string in assignees array may not properly detect if assignees already exist.

    @prfectionist
    Copy link

    prfectionist bot commented Nov 15, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Fix incorrect condition for checking empty assignees list in GitHub workflow

    The condition !contains(github.event.pull_request.assignees, '') is incorrect for
    checking if the PR has no assignees. Use github.event.pull_request.assignees.length
    == 0 instead.

    .github/workflows/auto-author-assign.yml [13]

    -if: ${{ !contains(github.event.pull_request.assignees, '') }}
    +if: ${{ github.event.pull_request.assignees.length == 0 }}
    Suggestion importance[1-10]: 9

    Why: The current condition using !contains with empty string is logically incorrect for checking empty assignees. The suggested fix using length check is the proper way to detect if a PR has no assignees, preventing potential workflow failures.

    9

    @beastawakens beastawakens merged commit d766573 into main Nov 15, 2024
    3 checks passed
    @beastawakens beastawakens deleted the auto-assign-author branch November 15, 2024 14:27
    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.

    2 participants