From 846da75445ed10c9e296c513a8b4d9b67e16489c Mon Sep 17 00:00:00 2001 From: Ou Date: Sat, 19 Oct 2024 15:08:42 +0800 Subject: [PATCH] feat(script): auto refresh data by action --- .github/workflows/auto-refresh.yml | 20 ++++++++++++++++++++ scripts/refresh.ts | 11 +++++++++++ 2 files changed, 31 insertions(+) create mode 100644 .github/workflows/auto-refresh.yml create mode 100644 scripts/refresh.ts diff --git a/.github/workflows/auto-refresh.yml b/.github/workflows/auto-refresh.yml new file mode 100644 index 0000000..76b1a79 --- /dev/null +++ b/.github/workflows/auto-refresh.yml @@ -0,0 +1,20 @@ +name: Auto Refresh + +on: + schedule: + - cron: '20 0-17,22,23 * * *' + workflow_dispatch: + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-node@v4 + with: + node-version: lts/* + + - run: npx tsx ./scripts/refresh.ts diff --git a/scripts/refresh.ts b/scripts/refresh.ts new file mode 100644 index 0000000..f710370 --- /dev/null +++ b/scripts/refresh.ts @@ -0,0 +1,11 @@ +import { sources } from "../shared/sources" +import { delay } from "../shared/utils" + +async function main() { + for (const id of Object.keys(sources)) { + await delay(100) + fetch(`https:newsnow.busiyi/api/s/${id}`) + } +} + +main().catch(console.error)