Skip to content

Commit

Permalink
Fix Discord messages being duplicated
Browse files Browse the repository at this point in the history
  • Loading branch information
DervexDev committed Sep 12, 2024
1 parent 625261e commit b05a22f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: Rensselaer-County/[email protected].9
- uses: Rensselaer-County/[email protected].10
with:
NOTION_API_KEY: ${{ secrets.NOTION_API_KEY }}
BUGS_DATABASE_ID: ${{ secrets.BUGS_DATABASE_ID }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: Rensselaer-County/[email protected].9
- uses: Rensselaer-County/[email protected].10
with:
NOTION_API_KEY: ${{ secrets.NOTION_API_KEY }}
BUGS_DATABASE_ID: ${{ secrets.BUGS_DATABASE_ID }}
Expand Down
2 changes: 1 addition & 1 deletion dist/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ function loadCache() {
if (!process.env.GITHUB_ACTIONS) {
return;
}
yield (0, cache_1.restoreCache)(PATHS, `${CACHE_KEY}-${Number(process.env.GITHUB_RUN_NUMBER) - 1}`, [`${CACHE_KEY}-`]);
PATHS.forEach((path) => {
if (!(0, fs_1.existsSync)(path)) {
(0, fs_1.writeFileSync)(path, "");
}
});
yield (0, cache_1.restoreCache)(PATHS, `${CACHE_KEY}-${Number(process.env.GITHUB_RUN_NUMBER) - 1}`, [`${CACHE_KEY}-`]);
});
}
function saveCache() {
Expand Down
12 changes: 5 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66838,11 +66838,6 @@ function loadCache() {
if (!process.env.GITHUB_ACTIONS) {
return;
}
PATHS.forEach((path) => {
if (!(0, fs_1.existsSync)(path)) {
(0, fs_1.writeFileSync)(path, "");
}
});
yield (0, cache_1.restoreCache)(PATHS, `${CACHE_KEY}-${Number(process.env.GITHUB_RUN_NUMBER) - 1}`, [`${CACHE_KEY}-`]);
});
}
Expand All @@ -66851,6 +66846,11 @@ function saveCache() {
if (!process.env.GITHUB_ACTIONS) {
return;
}
PATHS.forEach((path) => {
if (!(0, fs_1.existsSync)(path)) {
(0, fs_1.writeFileSync)(path, "");
}
});
yield (0, cache_1.saveCache)(PATHS, `${CACHE_KEY}-${process.env.GITHUB_RUN_NUMBER}`);
});
}
Expand Down Expand Up @@ -66925,8 +66925,6 @@ const dotenv_1 = __nccwpck_require__(2437);
const getInputs_1 = __importDefault(__nccwpck_require__(8687));
const cache_1 = __nccwpck_require__(4810);
const integrations_1 = __nccwpck_require__(8444);
const MAX_PAGE_AGE = 45; // in minutes
const MAX_PAGE_COUNT = 20;
if (!process.env.GITHUB_ACTIONS) {
(0, dotenv_1.configDotenv)();
}
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ export async function loadCache() {
return;
}

PATHS.forEach((path) => {
if (!existsSync(path)) {
writeFileSync(path, "");
}
});

await restore(
PATHS,
`${CACHE_KEY}-${Number(process.env.GITHUB_RUN_NUMBER) - 1}`,
Expand All @@ -29,6 +23,12 @@ export async function saveCache() {
return;
}

PATHS.forEach((path) => {
if (!existsSync(path)) {
writeFileSync(path, "");
}
});

await save(PATHS, `${CACHE_KEY}-${process.env.GITHUB_RUN_NUMBER}`);
}

Expand Down
7 changes: 0 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { Client } from "@notionhq/client";
import { DatabaseObjectResponse } from "@notionhq/client/build/src/api-endpoints";
import { APIEmbed, APIEmbedField } from "discord-api-types/v10";
import { configDotenv } from "dotenv";

import getInputs from "./getInputs";
import sendMessage from "./sendMessage";
import parseArrayProperty from "./parseArrayProperty";
import { loadCache, saveCache } from "./cache";
import { processIntegration } from "./integrations";

const MAX_PAGE_AGE = 45; // in minutes
const MAX_PAGE_COUNT = 20;

if (!process.env.GITHUB_ACTIONS) {
configDotenv();
}
Expand Down

0 comments on commit b05a22f

Please sign in to comment.