-
Notifications
You must be signed in to change notification settings - Fork 22
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
base: main
Are you sure you want to change the base?
Conversation
action.yml
Outdated
@@ -37,6 +42,18 @@ runs: | |||
using: "composite" | |||
steps: | |||
- run: | | |||
check_if_contributed_to_good_first_issue() { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
}
There was a problem hiding this comment.
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'
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Haimantika, do you have a repository where you tested this? That would help speed up the review process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you go - Haimantika/test_repo#6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created an issue without a good first issue label and I was able to take it, so existing functionality works. ✅
I tried taking an issue with a good first issue
label however and it let me take it even though it previously didn't allow you to take it. See Haimantika/test_repo#6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nickytonline I tried again now, works for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the changes I made are in the workflow. If you think it is good to go, I will update the PR here.
Closes #26.