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

Added logic to check if a contributor has already contributed to good first issue #28

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

Conversation

Haimantika
Copy link

  1. Added a check to see if the assignee has already contributed to a good first issue.
  2. If the check if true, then it returns a message.

Closes #26.

action.yml Outdated
@@ -37,6 +42,18 @@ runs:
using: "composite"
steps:
- run: |
check_if_contributed_to_good_first_issue() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

refactor (blocking): for the good first issue check, all that needs to be checked is if they've ever contributed to the repository, regardless of the labels.

Copy link
Author

Choose a reason for hiding this comment

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

Would something like this make sense:

check_if_contributed_to_repository() {
           local assignee="$1"
           local response=$(curl -s -H "Authorization: token $GITHUB_PAT" "https://api.github.com/search/issues?q=is:pr+author:$assignee")
           local total_count=$(echo "$response" | jq -r '.total_count')

           if [ "$total_count" -gt 0 ]; then
               echo "true"
           else
               echo "false"
           fi
       }

Copy link
Collaborator

Choose a reason for hiding this comment

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

This checks all issues. What I'd suggest is not even PRs or issues. If they have at least one commit in the given project, that disqualifies them from contributing to a good first issue.

Here's a rough example care of ChatGPT (don't necessarily trust it)

# Set your GitHub username, repository name, owner username, and access token
USERNAME="your_username"
REPO="repository_name"
OWNER="repository_owner_username"
ACCESS_TOKEN="your_access_token"

# Make a cURL request to list commits in the repository by the specified user
curl -H "Authorization: token $ACCESS_TOKEN" \
     -H "Accept: application/vnd.github.v3+json" \
     "https://api.github.com/repos/$OWNER/$REPO/commits?author=$USERNAME"

# You can filter the response to check if the user has commits
# For example, you can use 'jq' to parse JSON response and count the number of commits
# Ensure you have 'jq' installed: https://stedolan.github.io/jq/download/
# Example:
# curl -H "Authorization: token $ACCESS_TOKEN" \
#      -H "Accept: application/vnd.github.v3+json" \
#      "https://api.github.com/repos/$OWNER/$REPO/commits?author=$USERNAME" | jq '. | length'

Copy link
Author

Choose a reason for hiding this comment

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

Okay this makes sense. Thanks for clarifying, I will try to take a look over the weekend.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No rush @Haimantika, and thanks again for tackling this!

Copy link
Author

Choose a reason for hiding this comment

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

Hi @nickytonline do we want to make changes to the workflow? Or the action? Like I did a test here - Haimantika/test_repo#6 with updated workflow and it works.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @nickytonline any comments on it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @Haimantika, thanks again for working on this. I haven't had a chance to look at this yet as I'm deep in feature work currently for OpenSauced. I'm going to carve out some time for this in the next couple of weeks.

Copy link
Author

Choose a reason for hiding this comment

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

Hi @nickytonline ping on this - hoping you could take a look at it sometime in this month 😁

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hey @Haimantika, apologies, work has been busy and this went by the wayside.

I'm going to take a peek at this on Monday.

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

Successfully merging this pull request may close these issues.

Feature: Add an optional setting to only allow new contributors to take good first issues
2 participants