Skip to content

Commit a1b8bd6

Browse files
Update lunaria-report-bot.ts (#11)
* Update lunaria-report-bot.ts * refactor: simplify translation report message handling and add embeds * refactor: update Discord notification workflow to use new action and environment variables * fix: convert Discord embeds to JSON format in CI workflow * refactor: consolidate Discord message formatting by removing embed structure * fix: remove unused Discord embeds environment variable in CI workflow * refactor: simplify filtering logic for recent tracked changes in Discord message * Update scripts/lunaria-report-bot.ts Co-authored-by: Louis Escher <66965600+louisescher@users.noreply.github.com> --------- Co-authored-by: Louis Escher <66965600+louisescher@users.noreply.github.com>
1 parent bc6d0e9 commit a1b8bd6

File tree

2 files changed

+10
-32
lines changed

2 files changed

+10
-32
lines changed

.github/workflows/ci-report-lunaria.yml

+6-9
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ jobs:
2323
name: Format Discord message
2424
run: pnpm ci:lunaria:report
2525

26-
discord_message:
27-
name: Send Discord Message
28-
uses: withstudiocms/automations/.github/workflows/discord-msg.yml@main
29-
needs: translation
30-
secrets:
31-
DISCORD_WEBHOOK: ${{ secrets.DISCORD_I18N_REPORT }}
32-
with:
33-
DISCORD_MESSAGE: ${{ needs.translation.outputs.DISCORD_MESSAGE }}
34-
DISCORD_MESSAGE_EMBEDS: ${{ needs.translation.outputs.DISCORD_MESSAGE_EMBEDS }}
26+
- name: Send a Discord notification
27+
env:
28+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_I18N_REPORT }}
29+
uses: Ilshidur/action-discord@0.3.2
30+
with:
31+
args: "${{ steps.message.outputs.DISCORD_MESSAGE }}"

scripts/lunaria-report-bot.ts

+4-23
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,9 @@ async function setDiscordMessage() {
4646
})
4747
.join('\n');
4848

49-
let message = '**Weekly Translation Report Ready!** <@&1311284611799846942>';
50-
51-
let embedMessage = `We have ${Object.keys(toTranslate).length} pages with major changes since last week. Please help us translate these pages to your language!\n\n${list}`;
52-
53-
const embeds = [
54-
{
55-
id: 661098315,
56-
description: `We have ${Object.keys(toTranslate).length} pages with major changes since last week. Please help us translate these pages to your language!\n\n${list}`,
57-
fields: [],
58-
author: {
59-
name: 'Translation Report',
60-
icon_url:
61-
'https://github.com/withstudiocms/studiocms.dev/blob/main/assets/logo-discord.png?raw=true',
62-
},
63-
title: 'Translation Report',
64-
},
65-
];
49+
let message = `**The weekly translation report is here!** <@&1311284611799846942>\n\nWe have ${
50+
Object.keys(toTranslate).length
51+
} pages with major changes since last week. Please help us translate these pages to your language!\n\n${list}`;
6652

6753
const suffix =
6854
'\n\nSee our [Translation Status page](<https://i18n.docs.studiocms.dev>) for more, including open PRs.';
@@ -73,13 +59,8 @@ async function setDiscordMessage() {
7359
const lastNewline = message.lastIndexOf('\n', maxLengthWithoutSuffix);
7460
message = message.slice(0, lastNewline);
7561
}
76-
while (embedMessage.length > maxLengthWithoutSuffix) {
77-
const lastNewline = embedMessage.lastIndexOf('\n', maxLengthWithoutSuffix);
78-
embedMessage = embedMessage.slice(0, lastNewline);
79-
}
8062

81-
embedMessage += suffix;
63+
message += suffix;
8264

8365
setOutput('DISCORD_MESSAGE', message);
84-
setOutput('DISCORD_MESSAGE_EMBEDS', JSON.stringify(embeds));
8566
}

0 commit comments

Comments
 (0)