-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Aadesh Kulkarni
authored and
Aadesh Kulkarni
committed
Mar 15, 2024
1 parent
8786492
commit 3916e7f
Showing
5 changed files
with
71 additions
and
12 deletions.
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 |
---|---|---|
|
@@ -16,3 +16,4 @@ GUILD_ID = "123" | |
LOCAL_CMS_PROVIDER = true | ||
CACHE_EXPIRE_S = 10 | ||
ADMINS = "Random,[email protected]" | ||
DISCORD_BOUNTY_WEBHOOK=https://discord.com/api/webhooks/1218161863615840327/-ZztocKsF0JrVp04EVtsfAm4n3V1sjdv_nQ4x9IkGQJnwS4qUXa4-paIDxPxrlD9NRGK |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { extractBounty } from '@/lib/utils'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
export async function POST(req: NextRequest) { | ||
const data = await req.json(); | ||
const githubActionType = data.action; | ||
const isPR = data.issue.pull_request ? true : false; | ||
const PRTitle = data.issue.title; | ||
const PRURL = data.issue.html_url; | ||
const benefactor = data.comment.user.login; // hkirat | ||
const benefactorComment = data.comment.body; | ||
const bounty = extractBounty(benefactorComment); | ||
const bountyWinner = data.issue.user.login; | ||
const bountyWinnerProfile = data.issue.user.url; | ||
|
||
if ( | ||
githubActionType === 'created' && | ||
isPR && | ||
bounty && | ||
benefactor === 'hkirat' | ||
) { | ||
const message = `:moneybag: Congratulations, [${bountyWinner}](<${bountyWinnerProfile}>)! You've won a bounty of $${bounty} for working on [${PRTitle}](<${PRURL}>).`; | ||
await pushNotification(message); | ||
} | ||
|
||
return NextResponse.json({}); | ||
} | ||
|
||
async function pushNotification(content: any) { | ||
const DISCORD_WEBHOOK = process.env.DISCORD_BOUNTY_WEBHOOK; | ||
if (!DISCORD_WEBHOOK) { | ||
return; | ||
} | ||
const post = { | ||
content, | ||
}; | ||
const config = { | ||
method: 'POST', | ||
headers: { | ||
'content-type': 'application/json', | ||
}, | ||
body: JSON.stringify(post), | ||
}; | ||
await fetch(DISCORD_WEBHOOK, config); | ||
} |
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
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
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 |
---|---|---|
|
@@ -351,15 +351,10 @@ | |
resolved "https://registry.npmjs.org/@next/env/-/env-14.0.2.tgz" | ||
integrity sha512-HAW1sljizEaduEOes/m84oUqeIDAUYBR1CDwu2tobNlNDFP3cSm9d6QsOsGeNlIppU1p/p1+bWbYCbvwjFiceA== | ||
|
||
"@next/swc-linux-x64-gnu@14.0.2": | ||
"@next/swc-darwin-arm64@14.0.2": | ||
version "14.0.2" | ||
resolved "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.0.2.tgz" | ||
integrity sha512-WC9KAPSowj6as76P3vf1J3mf2QTm3Wv3FBzQi7UJ+dxWjK3MhHVWsWUo24AnmHx9qDcEtHM58okgZkXVqeLB+Q== | ||
|
||
"@next/[email protected]": | ||
version "14.0.2" | ||
resolved "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.0.2.tgz" | ||
integrity sha512-KSSAwvUcjtdZY4zJFa2f5VNJIwuEVnOSlqYqbQIawREJA+gUI6egeiRu290pXioQXnQHYYdXmnVNZ4M+VMB7KQ== | ||
resolved "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.0.2.tgz" | ||
integrity sha512-i+jQY0fOb8L5gvGvojWyZMfQoQtDVB2kYe7fufOEiST6sicvzI2W5/EXo4lX5bLUjapHKe+nFxuVv7BA+Pd7LQ== | ||
|
||
"@nodelib/[email protected]": | ||
version "2.1.5" | ||
|
@@ -2101,6 +2096,11 @@ fs.realpath@^1.0.0: | |
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" | ||
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== | ||
|
||
fsevents@~2.3.2: | ||
version "2.3.3" | ||
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" | ||
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== | ||
|
||
function-bind@^1.1.2: | ||
version "1.1.2" | ||
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz" | ||
|