Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
RajuGangitla committed Sep 17, 2024
2 parents c4f4d1f + 3ad5fa7 commit 066de0e
Show file tree
Hide file tree
Showing 16 changed files with 1,243 additions and 258 deletions.
9 changes: 4 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ S3_BUCKET_NAME=PLACEHOLDER
S3_REGION=PLACEHOLDER
S3_SECRET_KEY=PLACEHOLDER

#Trigger API credential URL(https://trigger.dev/docs/documentation/introduction)
TRIGGER_API_KEY=PLACEHOLDER
TRIGGER_API_URL=PLACEHOLDER

# Tremendous API credentials
TREMENDOUS_API_KEY=PLACEHOLDER
TREMENDOUS_CAMPAIGN_ID=PLACEHOLDER

# Discord Credentials
DISCORD_BOT_TOKEN=PLACEHOLDER
DISCORD_CHANNEL_ID=PLACEHOLDER
DISCORD_CHANNEL_ID=PLACEHOLDER

# Trigger.dev
TRIGGER_SECRET_KEY=PLACEHOLDER
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ next-env.d.ts
.vscode
.contentlayer

jobs/examples.ts
jobs/examples.ts
.trigger
10 changes: 0 additions & 10 deletions app/api/trigger/route.ts

This file was deleted.

4 changes: 0 additions & 4 deletions env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ export const env = createEnv({
GITHUB_APP_PRIVATE_KEY: z.string().min(1).optional(),
GITHUB_APP_SLUG: z.string().min(1),
GITHUB_APP_ACCESS_TOKEN: z.string().min(1),
TRIGGER_API_KEY: z.string().min(1),
TRIGGER_API_URL: z.string().min(1),
S3_BUCKET_NAME: z.string(),
S3_REGION: z.string(),
S3_ACCESS_KEY: z.string(),
Expand Down Expand Up @@ -62,8 +60,6 @@ export const env = createEnv({
S3_SECRET_KEY: process.env.S3_SECRET_KEY,
WEBAPP_URL: process.env.WEBAPP_URL,
VERCEL_URL: process.env.VERCEL_URL,
TRIGGER_API_KEY: process.env.TRIGGER_API_KEY,
TRIGGER_API_URL: process.env.TRIGGER_API_URL,
TREMENDOUS_API_KEY: process.env.TREMENDOUS_API_KEY,
TREMENDOUS_CAMPAIGN_ID: process.env.TREMENDOUS_CAMPAIGN_ID,
DISCORD_BOT_TOKEN: process.env.DISCORD_BOT_TOKEN,
Expand Down
32 changes: 0 additions & 32 deletions jobs/discordPointsMessage.ts

This file was deleted.

4 changes: 0 additions & 4 deletions jobs/index.ts

This file was deleted.

115 changes: 0 additions & 115 deletions jobs/issueReminder.ts

This file was deleted.

4 changes: 0 additions & 4 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@ export const GITHUB_APP_ACCESS_TOKEN = env.GITHUB_APP_ACCESS_TOKEN as string;

export const OSS_GG_LABEL = "🕹️ oss.gg" as const;

// Trigger.dev
export const TRIGGER_API_KEY = env.TRIGGER_API_KEY as string;
export const TRIGGER_API_URL = env.TRIGGER_API_URL as string;
export const ITEMS_PER_PAGE = 50;

// Storage constants
Expand All @@ -75,6 +72,5 @@ export const TREMENDOUS_CAMPAIGN_ID = env.TREMENDOUS_CAMPAIGN_ID;
// Discord
export const DISCORD_CHANNEL_ID = env.DISCORD_CHANNEL_ID;
export const DISCORD_BOT_TOKEN = env.DISCORD_BOT_TOKEN;
export const DISCORD_POINTS_MESSAGE_TRIGGER_ID = "discord.pointsMessage";
export const DISCORD_AWARD_POINTS_MESSAGE = (username: string, points: number) =>
`Way to go, ${username} 🎉 You've just earned ${points} points. Your contribution is invaluable to our community 🙌 Keep up the fantastic work and let's keep pushing forward! 💪`;
48 changes: 26 additions & 22 deletions lib/github/hooks/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
CREATE_IDENTIFIER,
DISCORD_AWARD_POINTS_MESSAGE,
DISCORD_CHANNEL_ID,
DISCORD_POINTS_MESSAGE_TRIGGER_ID,
EVENT_TRIGGERS,
LEVEL_LABEL,
ON_NEW_ISSUE,
Expand All @@ -16,10 +15,10 @@ import {
UNASSIGN_IDENTIFIER,
} from "@/lib/constants";
import { getRepositoryByGithubId } from "@/lib/repository/service";
import { getUser } from "@/lib/user/service";
import { triggerDotDevClient } from "@/trigger";
import { createUser, getUser, getUserByGithubId } from "@/lib/user/service";
import { discordPointMessageTask } from "@/src/trigger/discordPointsMessage";
import { issueReminderTask } from "@/src/trigger/issueReminder";
import { Webhooks } from "@octokit/webhooks";

import { isMemberOfRepository } from "../services/user";
import { checkOssGgLabel, extractIssueNumbers, extractIssueNumbersFromPrBody, extractPointsFromLabels, filterValidLabels, getOctokitInstance, postComment, processAndComment, processUserPoints } from "../utils";

Expand Down Expand Up @@ -173,22 +172,29 @@ export const onAssignCommented = async (webhooks: Webhooks) => {
});

//send trigger event to wait for 36hrs then send a reminder if the user has not created a pull request
await triggerDotDevClient.sendEvent({
name: "issue.reminder",
payload: {
issueNumber,
repo,
owner,
commenter,
installationId: context.payload.installation?.id,
},
});
try {
if (context.payload.installation?.id) {
await issueReminderTask.trigger({
issueNumber,
repo,
owner,
commenter,
installationId: context.payload.installation.id ?? "",
});
}
} catch (error) {
console.error("Error sending event:", error.message);
if (error.response) {
const responseText = await error.response.text(); // Capture response text
console.error("Response:", responseText);
}
}

await octokit.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body: `Assigned to @${commenter}! Excited to have you ship this 🕹️`,
body: `Assigned to @${commenter}! You have 48 hours to open a draft PR linking this issue. If we can't detect a PR, you will be unassigned automatically. Excited to have you ship this 🕹️`,
});
}

Expand Down Expand Up @@ -380,14 +386,12 @@ export const onAwardPoints = async (webhooks: Webhooks) => {
`Awarding ${user.login}: ${points} points! Check out your new contribution on [oss.gg/${user.login}](https://oss.gg/${user.login})` +
" " +
comment;

await triggerDotDevClient.sendEvent({
name: DISCORD_POINTS_MESSAGE_TRIGGER_ID,
payload: {
channelId: DISCORD_CHANNEL_ID,
message: DISCORD_AWARD_POINTS_MESSAGE(user.name ?? prAuthorUsername, points),
},

await discordPointMessageTask.trigger({
channelId: DISCORD_CHANNEL_ID,
message: DISCORD_AWARD_POINTS_MESSAGE(user.name ?? prAuthorUsername, points),
});

}
}

Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"db:setup": "pnpm db:up && pnpm db:migrate:dev",
"db:start": "pnpm db:setup",
"db:down": "docker-compose -f docker-compose.dev.yml down",
"dev": "pnpm db:start && next dev",
"build": "next build",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"lint": "next lint",
"start": "next start"
"start": "next start",
"dev:next": "pnpm db:start && next dev",
"dev:trigger": "pnpm dlx trigger.dev@beta dev",
"dev": "pnpm run dev:next & pnpm run dev:trigger"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.540.0",
Expand Down Expand Up @@ -47,9 +49,9 @@
"@tiptap/extension-typography": "^2.4.0",
"@tiptap/react": "^2.4.0",
"@tiptap/starter-kit": "^2.4.0",
"@trigger.dev/nextjs": "^2.3.18",
"@trigger.dev/react": "^2.3.18",
"@trigger.dev/sdk": "^2.3.18",
"@trigger.dev/nextjs": "3.0.0-beta.56",
"@trigger.dev/react": "3.0.0-beta.56",
"@trigger.dev/sdk": "3.0.0-beta.56",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"cmdk": "^1.0.0",
Expand Down Expand Up @@ -77,6 +79,7 @@
"tailwindcss-animate": "^1.0.7",
"tremendous": "3.0.1",
"uuid": "^9.0.1",
"v3": "link:@trigger.dev/sdk/v3",
"zod": "^3.23.8"
},
"devDependencies": {
Expand All @@ -88,6 +91,7 @@
"@types/react-dom": "^18.3.0",
"@types/react-syntax-highlighter": "^15.5.13",
"autoprefixer": "^10.4.19",
"concurrently": "^9.0.1",
"eslint": "^8.57.0",
"eslint-config-next": "14.1.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -106,8 +110,5 @@
"overrides": {
"undici": "5.27.0"
}
},
"trigger.dev": {
"endpointId": "oss-gg-dev-ND8k"
}
}
}
Loading

0 comments on commit 066de0e

Please sign in to comment.