Skip to content

Commit 244075e

Browse files
committed
feat: reduce cron to once a day
1 parent 4a986a7 commit 244075e

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Trusted by [![Repository Count][pull-stats-badge]][pull-website], triggered
2020
- ⚙️ **Flexible Configuration**: Customize sync behavior through
2121
`.github/pull.yml` configuration to accommodate different merge strategies,
2222
including merge, squash, rebase, and hard reset
23-
- 🕒 **Scheduled Updates**: Regularly checks for upstream changes every few
24-
hours to ensure forks are always up-to-date
23+
- 🕒 **Scheduled Updates**: Regularly checks for upstream changes periodically
24+
to ensure forks are always up-to-date
2525
- 👥 **Team Integration**: Facilitates collaboration by automatically adding
2626
assignees and reviewers to pull requests, honoring branch protection rules and
2727
working seamlessly with pull request checks and reviews
@@ -44,7 +44,7 @@ receive priority over other users)
4444
**[<img src="https://prod.download/pull-18h-svg" valign="bottom"/> Pull app][pull-app]**.
4545

4646
Pull app will automatically watch and pull in upstream's default (master) branch
47-
to yours using **hard reset** every few hours. You can also manually
47+
to yours using **hard reset** periodically. You can also manually
4848
[trigger](#trigger-manually) it anytime.
4949

5050
### Advanced Configuration (with config file)

src/configs/app-config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { readEnvOptions } from "probot/lib/bin/read-env-options.js";
2+
import denoJson from "@/deno.json" with { type: "json" };
23

34
function getAppConfig(env: Record<string, string> = Deno.env.toObject()) {
45
return {
56
...readEnvOptions(env),
7+
version: denoJson.version,
68
appName: env.APP_NAME || "Pull",
79
appSlug: env.APP_SLUG || "pull",
810
botName: `${env.APP_SLUG || "pull"}[bot]`,

src/router/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { Request, Response } from "express";
22
import type { Probot } from "probot";
33
import express from "express";
44
import { createSchedulerService } from "@wei/probot-scheduler";
5+
import { appConfig } from "@/src/configs/app-config.ts";
56
import getStatsHandlers from "@/src/router/stats.ts";
67
import getRepoHandlers from "@/src/router/repo-handler.ts";
78

@@ -15,6 +16,10 @@ const createRouter = (
1516
res.redirect("https://wei.github.io/pull");
1617
});
1718

19+
router.get("/version", (_req: Request, res: Response) => {
20+
res.json({ name: appConfig.appName, version: appConfig.version });
21+
});
22+
1823
router.get("/ping", (_req: Request, res: Response) => {
1924
res.json({ status: "pong" });
2025
});
@@ -28,6 +33,7 @@ const createRouter = (
2833
);
2934
router.get("/check/:owner/:repo", checkHandler);
3035
router.get("/process/:owner/:repo", processHandler);
36+
router.post("/process/:owner/:repo", processHandler);
3137

3238
return router;
3339
};

src/utils/helpers.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import denoJson from "@/deno.json" with { type: "json" };
1+
import { appConfig } from "@/src/configs/app-config.ts";
22

33
export const getRandomCronSchedule = () => {
4-
// Every 8 hours at a random minute
54
const randomMinute = Math.floor(Math.random() * 60);
6-
const randomHour1 = Math.floor(Math.random() * 8);
7-
const randomHour2 = randomHour1 + 8;
8-
const randomHour3 = randomHour2 + 8;
9-
return `${randomMinute} ${randomHour1},${randomHour2},${randomHour3} * * *`;
5+
const randomHour = Math.floor(Math.random() * 24);
6+
return `${randomMinute} ${randomHour} * * *`;
107
};
118

129
export const timeout = (ms: number): Promise<void> =>
@@ -19,5 +16,5 @@ export const getPRBody = (fullName: string, prNumber?: number): string =>
1916
(prNumber
2017
? `See [Commits](/${fullName}/pull/${prNumber}/commits) and [Changes](/${fullName}/pull/${prNumber}/files) for more details.`
2118
: `See Commits and Changes for more details.`) +
22-
`\n\n-----\nCreated by [<img src="https://prod.download/pull-18h-svg" valign="bottom"/> **pull[bot]** (v${denoJson.version})](https://github.com/wei/pull)` +
19+
`\n\n-----\nCreated by [<img src="https://prod.download/pull-18h-svg" valign="bottom"/> **pull[bot]**](https://github.com/wei/pull) (v${appConfig.version})` +
2320
"\n\n_Can you help keep this open source service alive? **[💖 Please sponsor : )](https://prod.download/pull-pr-sponsor)**_";

0 commit comments

Comments
 (0)