mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
feat: added cron job
This commit is contained in:
1 parent
6d9e6973d5
commit
622cd92a13
4 files changed
+33
-4
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
name: Host
|
name: CD Host
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
name: CD Ratings Leaderboard North America
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 5 * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
host:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Get code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Use node
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
|
||||||
|
- name: Generate leaderboard
|
||||||
|
run: GH_TOKEN=${{ secrets.GH_TOKEN }} yarn publish:ratingsleaderboard --region=asia
|
||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
node-version: [18.x]
|
node-version: [18.x]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Get code
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Use node
|
- name: Use node
|
||||||
|
|||||||
@@ -3,8 +3,16 @@ import { rm, writeFile } from 'fs/promises';
|
|||||||
import { argv, env } from 'process';
|
import { argv, env } from 'process';
|
||||||
import commitMultipleFiles from './commitMultipleFiles.js';
|
import commitMultipleFiles from './commitMultipleFiles.js';
|
||||||
|
|
||||||
|
/*
|
||||||
|
For Central North American Time (UTC-5), use 0 5 * * *.
|
||||||
|
For Central European Time (UTC+1), use 0 23 * * *.
|
||||||
|
For Central Asia Standard Time (UTC+7), use 0 17 * * *.
|
||||||
|
*/
|
||||||
|
|
||||||
const publish = argv.includes('--publish');
|
const publish = argv.includes('--publish');
|
||||||
const server = 'na';
|
const server = argv.find((arg) => arg.startsWith('--region='))?.split('=')[1];
|
||||||
|
|
||||||
|
if (!server) throw new Error('Region parameter not specified');
|
||||||
|
|
||||||
const NEIGHBORS = 1000;
|
const NEIGHBORS = 1000;
|
||||||
const PLAYERS = await fetch(
|
const PLAYERS = await fetch(
|
||||||
@@ -80,7 +88,7 @@ for (let index = 0; index < PLAYERS; index++) {
|
|||||||
const leaderboardJSON = JSON.stringify(leaderboard);
|
const leaderboardJSON = JSON.stringify(leaderboard);
|
||||||
|
|
||||||
if (publish) {
|
if (publish) {
|
||||||
const octokit = new Octokit({ auth: env.GITHUB_TOKEN });
|
const octokit = new Octokit({ auth: env.GH_TOKEN });
|
||||||
|
|
||||||
const info = await fetch(
|
const info = await fetch(
|
||||||
`https://${server}.wotblitz.com/en/api/rating-leaderboards/season/`,
|
`https://${server}.wotblitz.com/en/api/rating-leaderboards/season/`,
|
||||||
|
|||||||
Reference in new issue
Block a user