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 a reminder when contributor is new to ping all contributor bot #2484

Merged
merged 47 commits into from
Apr 11, 2024
Merged
Changes from 15 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5444909
a
KevinEyo1 Jan 29, 2024
a4a4d72
Revert test changes
KevinEyo1 Jan 29, 2024
ea3aca7
Merge branch 'MarkBind:master' into master
KevinEyo1 Feb 4, 2024
c0f79a2
Merge branch 'MarkBind:master' into master
KevinEyo1 Feb 9, 2024
45b8846
Merge branch 'MarkBind:master' into master
KevinEyo1 Feb 18, 2024
21628f7
Merge branch 'MarkBind:master' into master
KevinEyo1 Feb 28, 2024
969865f
Add how to check if permissions are given
yucheng11122017 Mar 12, 2024
46397e7
Merge branch 'master' of https://github.com/MarkBind/markbind
yucheng11122017 Mar 14, 2024
21fa90c
Merge branch 'master' of https://github.com/KevinEyo1/markbind
KevinEyo1 Mar 15, 2024
0bc66f7
Merge branch 'master' of https://github.com/MarkBind/markbind
yucheng11122017 Mar 17, 2024
0ebb7cd
Merge branch 'MarkBind:master' into master
KevinEyo1 Mar 18, 2024
f798b1d
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Mar 20, 2024
48399bd
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Mar 20, 2024
cb84513
Fix merge conflict
yucheng11122017 Mar 23, 2024
701183b
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Mar 25, 2024
4a83981
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Mar 29, 2024
85d3b9f
Add workflow
KevinEyo1 Mar 29, 2024
7e7cfb7
Merge branch 'master' of https://github.com/MarkBind/markbind
KevinEyo1 Mar 29, 2024
e5619fa
Merge branch 'master' into 2457-ping-new-contrib
KevinEyo1 Mar 29, 2024
2c9e6b4
Fix workflow
KevinEyo1 Mar 31, 2024
de03628
Merge branch 'master' into 2457-ping-new-contrib
KevinEyo1 Mar 31, 2024
15a926b
Update workflow
KevinEyo1 Mar 31, 2024
9a08f81
Merge branch '2457-ping-new-contrib' of https://github.com/KevinEyo1/…
KevinEyo1 Mar 31, 2024
79a6363
Update action
KevinEyo1 Mar 31, 2024
2b43560
Add echo
KevinEyo1 Apr 2, 2024
64c280d
Add log
KevinEyo1 Apr 2, 2024
01a0637
Update workflow
KevinEyo1 Apr 3, 2024
c4e8b52
Merge branch 'master' into 2457-ping-new-contrib
KevinEyo1 Apr 3, 2024
e2f6301
Allocate space for scrollbar in nav components
jingting1412 Apr 5, 2024
eb69423
Fix merge conflict
yucheng11122017 Apr 5, 2024
c9c05c2
Merge branch 'master' into 2457-ping-new-contrib
KevinEyo1 Apr 5, 2024
936dadc
Fix merge conflict
yucheng11122017 Apr 5, 2024
30d31f7
Test time
KevinEyo1 Apr 5, 2024
6056ba5
Merge branch '2457-ping-new-contrib' of https://github.com/KevinEyo1/…
KevinEyo1 Apr 5, 2024
88405dd
Remove logs
KevinEyo1 Apr 5, 2024
cfeffed
Merge branch 'master' into 2457-ping-new-contrib
KevinEyo1 Apr 5, 2024
5b9e7d7
Revert "Fix merge conflict"
yucheng11122017 Apr 5, 2024
c092296
Merge branch 'master' into 2457-ping-new-contrib
KevinEyo1 Apr 5, 2024
30996b3
Merge branch 'master' into 2457-ping-new-contrib
KevinEyo1 Apr 5, 2024
d6324a3
Merge branch 'master' into 2457-ping-new-contrib
KevinEyo1 Apr 7, 2024
7b5d6a9
Update files
KevinEyo1 Apr 7, 2024
b695c9b
Improve security and upadte message
KevinEyo1 Apr 9, 2024
6db70bc
Merge branch 'master' into 2457-ping-new-contrib
KevinEyo1 Apr 9, 2024
8832b1a
Merge branch 'master' into 2457-ping-new-contrib
KevinEyo1 Apr 10, 2024
7c00b6e
Revert to version number
KevinEyo1 Apr 11, 2024
7e26f6f
Rename variable
KevinEyo1 Apr 11, 2024
03bde6f
Merge branch 'master' into 2457-ping-new-contrib
yucheng11122017 Apr 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/new-contributor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: New Contributor Action
on:
pull_request_target:
types:
- closed

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
ping-new-contributor:
if: ${{ github.event.pull_request.merged }}
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v7
with:
script: |
const creator = context.payload.sender.login
const opts = github.rest.issues.listForRepo.endpoint.merge({
...context.issue,
creator,
state: 'all'
})
const issues = await github.paginate(opts)

for (const issue of issues) {
if (issue.number === context.issue.number) {
continue
}

if (issue.pull_request) {
return // Creator is already a contributor.
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This part lgtm but I am thinking of an alternative

Instead of checking all prs and see if there is any previous prs by the pr creator, I am thinking if we could utilise Github's built-in function to get the current list of contributors and check if the person is inside

https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-repository-contributors

Not sure if this approach would speed up the process since we do not have to go through every closed pr

Copy link
Contributor Author

@KevinEyo1 KevinEyo1 Mar 30, 2024

Choose a reason for hiding this comment

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

Hi @LamJiuFong, thanks for the suggestion, I think it will be more efficient.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the changes @KevinEyo1 ! LGTM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @LamJiuFong after testing, I realised that since we are running the job on merge, the author is already part of the list by the time the action is run, so it fails to detect the author as a new contributor. I will revert to the original implementation, and I will try to figure out if there can be performance enhancements.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, sorry for missing that out

What about checking if the author has only one pr merged (which is the newly merged one), would that be possible?

Copy link
Contributor

Choose a reason for hiding this comment

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

@LamJiuFong I am trying to think of a more efficient solution as well but I think to check if the author has only one PR merged we would have to fetch all the PRs anyway (which is what is done in the current implementation) leading to a similar time taken

Copy link
Contributor

Choose a reason for hiding this comment

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

Spoke to Kevin about this previously and he did this check: Test run to check time which wasn't very long. So I don't think there is a need to overoptimize in this case.


await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `**Welcome**, new contributor!

Do remember to request someone to add you as a official contributor to our repository, if you want to of course! See the full list of contributors [here](https://markbind.org/about.html) ✨`
})
Loading