feat: nightly build notify

This commit is contained in:
DarkSky 2022-12-18 00:51:15 +08:00
parent 7719f7a86e
commit c62e5f2985
2 changed files with 18 additions and 1 deletions

View File

@ -9,7 +9,8 @@
"start": "pnpm --filter @pathfinder/app start", "start": "pnpm --filter @pathfinder/app start",
"lint": "pnpm --filter @pathfinder/app lint", "lint": "pnpm --filter @pathfinder/app lint",
"test:e2e": "playwright test", "test:e2e": "playwright test",
"test:unit": "jest" "test:unit": "jest",
"notify": "node --experimental-modules scripts/notify.mjs"
}, },
"devDependencies": { "devDependencies": {
"@jest/globals": "^29.3.1", "@jest/globals": "^29.3.1",

16
scripts/notify.mjs Normal file
View File

@ -0,0 +1,16 @@
import got from 'got';
const STAGE_HOST = 'https://nightly.affine.pro/';
if (['master', 'develop'].includes(process.env.CF_PAGES_BRANCH)) {
const message = `Daily builds: New deployment of PathFinder version ${process.env.CF_PAGES_COMMIT_SHA} was deploy: [nightly](${STAGE_HOST}) / [internal](${process.env.CF_PAGES_URL})`;
const url = `https://api.telegram.org/bot${process.env.BOT_TOKEN}/sendMessage`;
got.post(url, {
json: {
chat_id: process.env.CHAT_ID,
text: message,
parse_mode: 'Markdown',
disable_notification: true,
},
}).then(r => console.log(r.body));
}