Skip to content

Commit

Permalink
fix: trigger functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhruwang committed Sep 13, 2024
1 parent 41b8359 commit dc410d2
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 74 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ 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
Expand Down
4 changes: 2 additions & 2 deletions jobs/issueReminder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ triggerDotDevClient.defineJob({
const octokit = getOctokitInstance(installationId);

//wait for 36hrs
await io.wait("waiting for 36hrs", 36 * 60 * 60);
await io.wait("waiting for 36hrs", 5);

//made this a task so it doesn't get replayed
const taskValue = await io.runTask("36-hrs", async () => {
Expand Down Expand Up @@ -80,7 +80,7 @@ triggerDotDevClient.defineJob({
if (taskValue?.completed) {
return;
} else {
await io.wait("waiting for 12hrs", 12 * 60 * 60);
await io.wait("waiting for 12hrs", 60);

await io.runTask("48-hrs", async () => {
const pullRequest = await findPullRequestByIssueAndCommenter(
Expand Down
1 change: 0 additions & 1 deletion lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ 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 Down
28 changes: 18 additions & 10 deletions lib/github/hooks/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,24 @@ 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 {
await triggerDotDevClient.sendEvent({
name: "issue.reminder",
payload: {
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,
Expand Down
17 changes: 10 additions & 7 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": "concurrently --kill-others npm:dev:*",
"dev:next": "pnpm db:start && next dev",
"dev:trigger": "npx @trigger.dev/cli dev"
},
"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": "^2.3.19",
"@trigger.dev/react": "^2.3.19",
"@trigger.dev/sdk": "^2.3.19",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"cmdk": "^1.0.0",
Expand Down Expand Up @@ -88,6 +90,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 @@ -108,6 +111,6 @@
}
},
"trigger.dev": {
"endpointId": "oss-gg-dev-ND8k"
"endpointId": "test-989w"
}
}
}
Loading

0 comments on commit dc410d2

Please sign in to comment.