-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Create congratulations bot #5404
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fe43591
modified og image + created endpoint for contributor stats
ady-test ef6e1cc
create bot
ady-beraud cfa260d
add png
ady-beraud 9d51cd9
added correct link
ady-beraud adef3da
added job to ci
ady-beraud 7ca48d5
added team members + removed congratulate for first PR
ady-beraud 519166c
added partial sync
ady-beraud aca6281
Merge branch 'main' into create-congratulations-bot
ady-beraud f97d3c2
fix sync
ady-beraud 375518b
fix sync
ady-beraud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
added team members + removed congratulate for first PR
- Loading branch information
commit 7ca48d5a01994d5fb9c440fac20d031063690cef
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,26 +23,63 @@ const fetchContributorImage = async (username: string) => { | |
await fetch(apiUrl); | ||
}; | ||
|
||
const getTeamMembers = async () => { | ||
const org = 'twentyhq'; | ||
const team_slug = 'core-team'; | ||
const response = await danger.github.api.teams.listMembersInOrg({ | ||
org, | ||
team_slug, | ||
}); | ||
return response.data.map((user) => user.login); | ||
}; | ||
|
||
const runCongratulate = async () => { | ||
const pullRequest = danger.github.pr; | ||
const userName = pullRequest.user.login; | ||
|
||
const staticExcludedUsers = [ | ||
'dependabot', | ||
'cyborch', | ||
'emilienchvt', | ||
'Samox', | ||
'charlesBochet', | ||
'gitstart-app', | ||
'thaisguigon', | ||
'lucasbordeau', | ||
'magrinj', | ||
'Weiko', | ||
'gitstart-twenty', | ||
'bosiraphael', | ||
'martmull', | ||
'FelixMalfait', | ||
'thomtrp', | ||
'Bonapara', | ||
'nimraahmed', | ||
'ady-beraud', | ||
]; | ||
|
||
const teamMembers = await getTeamMembers(); | ||
|
||
const excludedUsers = new Set([...staticExcludedUsers, ...teamMembers]); | ||
|
||
if (excludedUsers.has(userName)) { | ||
return; | ||
} | ||
|
||
const { data: pullRequests } = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this going to be posted on every PR? We want to discard the |
||
await danger.github.api.rest.search.issuesAndPullRequests({ | ||
q: `is:pr author:${userName} is:closed repo:twentyhq/twenty`, | ||
per_page: 2, | ||
page: 1, | ||
}); | ||
|
||
let stats; | ||
const isFirstPR = pullRequests.total_count === 1; | ||
|
||
if (!isFirstPR) { | ||
stats = await fetchContributorStats(userName); | ||
} else { | ||
stats = { mergedPRsCount: 1, rank: 52 }; | ||
if (isFirstPR) { | ||
return; | ||
} | ||
|
||
const stats = await fetchContributorStats(userName); | ||
const contributorUrl = `https://twenty.com/contributors/${userName}`; | ||
|
||
// Pre-fetch to trigger cloudflare cache | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In a follow-up PR could you please cleanup the code and make sure we have one source of truth for that list of users? We don't want to have to modify it in different places