From 30cb0dc69eabc0fae282836489a8564a059efd40 Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 2 Mar 2026 10:35:10 +0000 Subject: [PATCH 1/7] print the api errors --- post-message/index.mjs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/post-message/index.mjs b/post-message/index.mjs index a9f0a59..d7cf082 100644 --- a/post-message/index.mjs +++ b/post-message/index.mjs @@ -9,6 +9,7 @@ try { chat: chatId, text, }); + const response = await fetch("https://api.ro.am/v0/chat.post", { method: "POST", headers: { @@ -17,12 +18,20 @@ try { }, body, }); + if (!response.ok) { - throw new Error(`HTTP error! status: ${response.status}`); + const errorBody = await response.text(); + + core.error(`API request failed`); + core.error(`Status: ${response.status} ${response.statusText}`); + core.error(`Response body: ${errorBody}`); + + throw new Error(`HTTP ${response.status}`); } const responseData = await response.json(); console.log("Response:", responseData); + } catch (error) { core.setFailed(error.message); -} +} \ No newline at end of file From 59eca1bf04933b66ab6e424fbee4e04ae1310a46 Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 2 Mar 2026 15:34:05 +0000 Subject: [PATCH 2/7] changing payload to use blocks --- post-message/index.mjs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/post-message/index.mjs b/post-message/index.mjs index d7cf082..6eaaeea 100644 --- a/post-message/index.mjs +++ b/post-message/index.mjs @@ -4,10 +4,22 @@ try { const apiKey = core.getInput("api-key"); const chatId = core.getInput("chat-id"); const text = core.getInput("text"); + const jobStatus = core.getInput("job-status"); + + const color = jobStatus === "success" ? "good" : "danger"; // const body = JSON.stringify({ chat: chatId, - text, + color: color, + blocks: [ + { + type: "section", + text: { + type: "mrkdwn", + text: text + } + } + ] }); const response = await fetch("https://api.ro.am/v0/chat.post", { @@ -21,11 +33,9 @@ try { if (!response.ok) { const errorBody = await response.text(); - core.error(`API request failed`); core.error(`Status: ${response.status} ${response.statusText}`); core.error(`Response body: ${errorBody}`); - throw new Error(`HTTP ${response.status}`); } From 8f7aec7150c36ce7b95d9f932fff7e6b84ec8dcb Mon Sep 17 00:00:00 2001 From: josh Date: Tue, 3 Mar 2026 09:07:56 +0000 Subject: [PATCH 3/7] update for nicer formatting --- post-message/action.yml | 2 ++ post-message/index.mjs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/post-message/action.yml b/post-message/action.yml index 585e24a..759b9c1 100644 --- a/post-message/action.yml +++ b/post-message/action.yml @@ -7,6 +7,8 @@ inputs: required: true text: required: true + link: + required: true runs: using: node20 main: index.mjs diff --git a/post-message/index.mjs b/post-message/index.mjs index 6eaaeea..43fc43c 100644 --- a/post-message/index.mjs +++ b/post-message/index.mjs @@ -4,6 +4,7 @@ try { const apiKey = core.getInput("api-key"); const chatId = core.getInput("chat-id"); const text = core.getInput("text"); + const link = core.getInput("link"); const jobStatus = core.getInput("job-status"); const color = jobStatus === "success" ? "good" : "danger"; // @@ -18,7 +19,15 @@ try { type: "mrkdwn", text: text } + }, + { "type": "divider" }, + { + type: "context", + elements: { + type: "mrkdwn", + text: link } + } ] }); From bc4e06b6a4256df2a70f953f71c358e90e4287be Mon Sep 17 00:00:00 2001 From: josh Date: Tue, 3 Mar 2026 09:37:35 +0000 Subject: [PATCH 4/7] update action to take in an object and add handling of non deployment/ success message --- post-message/action.yml | 10 +++++++--- post-message/index.mjs | 31 +++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/post-message/action.yml b/post-message/action.yml index 759b9c1..0afb368 100644 --- a/post-message/action.yml +++ b/post-message/action.yml @@ -3,12 +3,16 @@ name: Post Chat Message inputs: api-key: required: true + description: api key to authenticate to ROAM api chat-id: required: true - text: - required: true - link: + description: id of the chat to post the message to + payload: required: true + description: contents of the message JSON object {title - string, text - string, link - string} + job-status: + required: false + description: status of the job that triggered the message runs: using: node20 main: index.mjs diff --git a/post-message/index.mjs b/post-message/index.mjs index 43fc43c..e4cc676 100644 --- a/post-message/index.mjs +++ b/post-message/index.mjs @@ -3,16 +3,25 @@ import core from "@actions/core"; try { const apiKey = core.getInput("api-key"); const chatId = core.getInput("chat-id"); - const text = core.getInput("text"); - const link = core.getInput("link"); + const payloadInput = core.getInput("payload"); const jobStatus = core.getInput("job-status"); - const color = jobStatus === "success" ? "good" : "danger"; // + let payload = JSON.parse(payloadInput); + const { title, text, link } = payload; + + const color = jobStatus ? (jobStatus === "success" ? "good" : "danger") : "warning"; const body = JSON.stringify({ chat: chatId, color: color, blocks: [ + { + type: "header", + text: { + type: "mrkdwn", + text: title + } + }, { type: "section", text: { @@ -20,14 +29,16 @@ try { text: text } }, - { "type": "divider" }, - { - type: "context", - elements: { - type: "mrkdwn", - text: link + { type: "divider" }, + { + type: "context", + elements: [ + { + type: "mrkdwn", + text: link + } + ] } - } ] }); From 304ce60acbdab0666046422ad13acb4c0d4fcbeb Mon Sep 17 00:00:00 2001 From: josh Date: Tue, 3 Mar 2026 10:22:13 +0000 Subject: [PATCH 5/7] using blocks and passing in colour --- post-message/action.yml | 14 +++++++------- post-message/index.mjs | 42 +++++++---------------------------------- 2 files changed, 14 insertions(+), 42 deletions(-) diff --git a/post-message/action.yml b/post-message/action.yml index 0afb368..a78ec3c 100644 --- a/post-message/action.yml +++ b/post-message/action.yml @@ -3,16 +3,16 @@ name: Post Chat Message inputs: api-key: required: true - description: api key to authenticate to ROAM api + description: API key to authenticate with the Roam API chat-id: required: true - description: id of the chat to post the message to - payload: + description: Chat ID of the Roam group the message will be sent to + blocks: required: true - description: contents of the message JSON object {title - string, text - string, link - string} - job-status: - required: false - description: status of the job that triggered the message + description: Blocks Array of the message contents + colour: + required: true + description: Colour of the Roam notification banner runs: using: node20 main: index.mjs diff --git a/post-message/index.mjs b/post-message/index.mjs index e4cc676..38d76bb 100644 --- a/post-message/index.mjs +++ b/post-message/index.mjs @@ -3,44 +3,16 @@ import core from "@actions/core"; try { const apiKey = core.getInput("api-key"); const chatId = core.getInput("chat-id"); - const payloadInput = core.getInput("payload"); - const jobStatus = core.getInput("job-status"); + const color = core.getInput("colour"); + const blocksInput = core.getInput("blocks"); - let payload = JSON.parse(payloadInput); - const { title, text, link } = payload; - - const color = jobStatus ? (jobStatus === "success" ? "good" : "danger") : "warning"; + const blocks = JSON.parse(blocksInput); const body = JSON.stringify({ - chat: chatId, - color: color, - blocks: [ - { - type: "header", - text: { - type: "mrkdwn", - text: title - } - }, - { - type: "section", - text: { - type: "mrkdwn", - text: text - } - }, - { type: "divider" }, - { - type: "context", - elements: [ - { - type: "mrkdwn", - text: link - } - ] - } - ] - }); + chat: chatId, + color, + blocks + }); const response = await fetch("https://api.ro.am/v0/chat.post", { method: "POST", From 2a1e31d59703e3ccf0e9dd95d697fbcf17c13ebd Mon Sep 17 00:00:00 2001 From: josh Date: Tue, 3 Mar 2026 13:24:55 +0000 Subject: [PATCH 6/7] debug input --- post-message/index.mjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/post-message/index.mjs b/post-message/index.mjs index 38d76bb..ee99e61 100644 --- a/post-message/index.mjs +++ b/post-message/index.mjs @@ -6,6 +6,8 @@ try { const color = core.getInput("colour"); const blocksInput = core.getInput("blocks"); + console.log(blocksInput); + const blocks = JSON.parse(blocksInput); const body = JSON.stringify({ From 9bf8c013fe401f76ef3dd034fabdff7caaa6cff7 Mon Sep 17 00:00:00 2001 From: josh Date: Tue, 3 Mar 2026 13:52:20 +0000 Subject: [PATCH 7/7] handle json formatting in the action and take string then parse back --- post-message/index.mjs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/post-message/index.mjs b/post-message/index.mjs index ee99e61..7223a0a 100644 --- a/post-message/index.mjs +++ b/post-message/index.mjs @@ -4,17 +4,15 @@ try { const apiKey = core.getInput("api-key"); const chatId = core.getInput("chat-id"); const color = core.getInput("colour"); - const blocksInput = core.getInput("blocks"); + const blocks = core.getInput("blocks"); - console.log(blocksInput); - - const blocks = JSON.parse(blocksInput); + console.log(blocks); const body = JSON.stringify({ - chat: chatId, - color, - blocks - }); + chat: chatId, + color, + blocks: JSON.parse(blocks) + }); const response = await fetch("https://api.ro.am/v0/chat.post", { method: "POST",