Skip to content

Commit

Permalink
v2 -> v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruwang committed Sep 16, 2024
1 parent dc410d2 commit 6d70456
Show file tree
Hide file tree
Showing 15 changed files with 1,199 additions and 259 deletions.
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.

2 changes: 0 additions & 2 deletions env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const env = createEnv({
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 @@ -63,7 +62,6 @@ export const env = createEnv({
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.

1 change: 0 additions & 1 deletion lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,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! 💪`;
24 changes: 10 additions & 14 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 @@ -18,7 +17,8 @@ import {
import { assignUserPoints } from "@/lib/points/service";
import { getRepositoryByGithubId } from "@/lib/repository/service";
import { createUser, getUser, getUserByGithubId } from "@/lib/user/service";
import { triggerDotDevClient } from "@/trigger";
import { discordPointMessageTask } from "@/src/trigger/discordPointsMessage";
import { issueReminderTask } from "@/src/trigger/issueReminder";
import { Webhooks } from "@octokit/webhooks";

import { isMemberOfRepository } from "../services/user";
Expand Down Expand Up @@ -176,16 +176,15 @@ 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
try {
await triggerDotDevClient.sendEvent({
name: "issue.reminder",
payload: {
if (context.payload.installation?.id) {
await issueReminderTask.trigger({
issueNumber,
repo,
owner,
commenter,
installationId: context.payload.installation?.id,
},
});
installationId: context.payload.installation.id ?? "",
});
}
} catch (error) {
console.error("Error sending event:", error.message);
if (error.response) {
Expand Down Expand Up @@ -400,12 +399,9 @@ 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
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"lint": "next lint",
"start": "next start",
"dev": "concurrently --kill-others npm:dev:*",
"dev:next": "pnpm db:start && next dev",
"dev:trigger": "npx @trigger.dev/cli 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 @@ -49,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.19",
"@trigger.dev/react": "^2.3.19",
"@trigger.dev/sdk": "^2.3.19",
"@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 @@ -79,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 Down
Loading

0 comments on commit 6d70456

Please sign in to comment.