Skip to content

Commit

Permalink
Refactor discord.js to update DISCORD_MESSAGE_EMBEDS handling and fix…
Browse files Browse the repository at this point in the history
… message embeds bug
  • Loading branch information
Adammatthiesen committed Nov 28, 2024
1 parent b032650 commit c66c037
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 19 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/test_send-discord-hook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ jobs:
- name: Send message on Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_TEST_HOOK }}
# DISCORD_MESSAGE: "Test message from GitHub Actions"
DISCORD_MESSAGE_EMBEDS: >
[
{
"id": 661098315,
"description": "Just a test message from GitHub Actions.",
"fields": [],
"author": {
"name": "withStudioCMS Test Bot",
"icon_url": "https://github.com/withstudiocms/studiocms.dev/blob/main/assets/logo-discord.png?raw=true"
},
"title": "Hello, world!",
}
]
DISCORD_MESSAGE: "Test message from GitHub Actions"
# DISCORD_MESSAGE_EMBEDS: >
# [
# {
# "id": 661098315,
# "description": "Just a test message from GitHub Actions.",
# "fields": [],
# "author": {
# "name": "withStudioCMS Test Bot",
# "icon_url": "https://github.com/withstudiocms/studiocms.dev/blob/main/assets/logo-discord.png?raw=true"
# },
# "title": "Hello, world!",
# }
# ]
run: node automation/scripts/discord.js
5 changes: 0 additions & 5 deletions scripts/discord.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ if (!GITHUB_ACTION || !DISCORD_WEBHOOK) {
);
}

console.log("DISCORD_MESSAGE", DISCORD_MESSAGE);
console.log("DISCORD_MESSAGE_EMBEDS", DISCORD_MESSAGE_EMBEDS);

function parseDiscordEmbeds(jsonString) {
try {
// Fix common JSON formatting issues:
Expand Down Expand Up @@ -54,8 +51,6 @@ function getBody() {

const body = getBody();

console.log("MESSAGE_BODY", body);

if (DISCORD_USERNAME) {
body.username = DISCORD_USERNAME;
}
Expand Down

0 comments on commit c66c037

Please sign in to comment.