Commit d2d753dd by Lin Wang

feat: add the notify-slack command line

parent 43875f1c
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
"task:slack": "bun run task && bun run send-diff", "task:slack": "bun run task && bun run send-diff",
"task:slack:ai": "bun run task:ai && bun run send-diff", "task:slack:ai": "bun run task:ai && bun run send-diff",
"task:gsheet": "bun run task && bun run send-gsheet", "task:gsheet": "bun run task && bun run send-gsheet",
"task:gsheet:ai": "bun run task:ai && USE_AI_SELECTORS=true bun run send-gsheet" "task:gsheet:ai": "bun run task:ai && USE_AI_SELECTORS=true bun run send-gsheet",
"notify-slack": "bun run src/detect_section_selector_masters/sendNotifySlack.ts"
} }
} }
\ No newline at end of file
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
import { google } from 'googleapis'; import { google } from 'googleapis';
import { readdirSync, readFileSync } from 'fs'; import { readdirSync, readFileSync } from 'fs';
import { join } from 'path'; import { join } from 'path';
import { sendSlackMessage } from '../clients/slack';
async function uploadAllToSheets() { async function uploadAllToSheets() {
const useAiSelectors = process.env.USE_AI_SELECTORS === 'true'; const useAiSelectors = process.env.USE_AI_SELECTORS === 'true';
...@@ -62,20 +61,9 @@ async function uploadAllToSheets() { ...@@ -62,20 +61,9 @@ async function uploadAllToSheets() {
} }
} }
async function notifySlack() {
const webhookUrl = process.env.SLACK_WEBHOOK!;
const nonAiUrl = `https://docs.google.com/spreadsheets/d/${process.env.GOOGLE_SHEET_ID}/edit`;
const aiUrl = `https://docs.google.com/spreadsheets/d/${process.env.GOOGLE_SHEET_AI_ID}/edit`;
await sendSlackMessage(webhookUrl, {
issue: 'Inconsistencies are detected in i18n master section template',
details: `Google Sheet Links:\n- Non-AI selectors: ${nonAiUrl}\n- AI selectors: ${aiUrl}`
});
}
async function main() { async function main() {
try { try {
await uploadAllToSheets(); await uploadAllToSheets();
await notifySlack();
} catch (err) { } catch (err) {
console.error('Error in task:gsheet workflow:', err); console.error('Error in task:gsheet workflow:', err);
process.exit(1); process.exit(1);
......
import { sendSlackMessage } from '../clients/slack';
async function main() {
const webhookUrl = process.env.SLACK_WEBHOOK!;
const nonAiUrl = `https://docs.google.com/spreadsheets/d/${process.env.GOOGLE_SHEET_ID}/edit`;
const aiUrl = `https://docs.google.com/docs.google.com/spreadsheets/d/${process.env.GOOGLE_SHEET_AI_ID}/edit`;
await sendSlackMessage(webhookUrl, {
issue: 'Inconsistencies are detected in i18n master section template',
details: `Google Sheet Links:\n- Non-AI selectors: ${nonAiUrl}\n- AI selectors: ${aiUrl}`
});
}
main().catch(err => {
console.error(err);
process.exit(1);
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment