From c62e5f2985e34a4e3c70a47b6977734bfcf8e9ef Mon Sep 17 00:00:00 2001 From: DarkSky Date: Sun, 18 Dec 2022 00:51:15 +0800 Subject: [PATCH] feat: nightly build notify --- package.json | 3 ++- scripts/notify.mjs | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 scripts/notify.mjs diff --git a/package.json b/package.json index 712288570f..6c86a91b81 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "start": "pnpm --filter @pathfinder/app start", "lint": "pnpm --filter @pathfinder/app lint", "test:e2e": "playwright test", - "test:unit": "jest" + "test:unit": "jest", + "notify": "node --experimental-modules scripts/notify.mjs" }, "devDependencies": { "@jest/globals": "^29.3.1", diff --git a/scripts/notify.mjs b/scripts/notify.mjs new file mode 100644 index 0000000000..b404731546 --- /dev/null +++ b/scripts/notify.mjs @@ -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)); +}