Skip to content

Commit

Permalink
Fix cache being saved before writing pages
Browse files Browse the repository at this point in the history
  • Loading branch information
DervexDev committed Sep 12, 2024
1 parent b05a22f commit 895352f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 12 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].10
- uses: Rensselaer-County/[email protected].11
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].10
- uses: Rensselaer-County/[email protected].11
with:
NOTION_API_KEY: ${{ secrets.NOTION_API_KEY }}
BUGS_DATABASE_ID: ${{ secrets.BUGS_DATABASE_ID }}
Expand Down
10 changes: 5 additions & 5 deletions dist/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ function loadCache() {
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, "");
}
});
});
}
function saveCache() {
return __awaiter(this, void 0, void 0, function* () {
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
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66934,8 +66934,8 @@ if (!process.env.GITHUB_ACTIONS) {
auth: NOTION_API_KEY,
});
yield (0, cache_1.loadCache)();
(0, integrations_1.processIntegration)(notion, BUGS_DATABASE_ID, BUGS_WEBHOOK_URL, "bugs");
(0, integrations_1.processIntegration)(notion, TASKS_DATABASE_ID, TASKS_WEBHOOK_URL, "tasks");
yield (0, integrations_1.processIntegration)(notion, BUGS_DATABASE_ID, BUGS_WEBHOOK_URL, "bugs");
yield (0, integrations_1.processIntegration)(notion, TASKS_DATABASE_ID, TASKS_WEBHOOK_URL, "tasks");
yield (0, cache_1.saveCache)();
}))();

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/integrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function processIntegration(notion, databaseId, webhookUrl, integration) {
currentPageId = yield (0, tasks_1.default)(response, webhookUrl, lastPageId);
}
if (currentPageId) {
console.log(2);
(0, cache_1.setCurrentPageId)(integration, currentPageId);
}
});
Expand Down
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ if (!process.env.GITHUB_ACTIONS) {

await loadCache();

processIntegration(notion, BUGS_DATABASE_ID, BUGS_WEBHOOK_URL, "bugs");
processIntegration(notion, TASKS_DATABASE_ID, TASKS_WEBHOOK_URL, "tasks");
await processIntegration(notion, BUGS_DATABASE_ID, BUGS_WEBHOOK_URL, "bugs");
await processIntegration(
notion,
TASKS_DATABASE_ID,
TASKS_WEBHOOK_URL,
"tasks",
);

await saveCache();
})();

0 comments on commit 895352f

Please sign in to comment.