Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion post-message/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ name: Post Chat Message
inputs:
api-key:
required: true
description: API key to authenticate with the Roam API
chat-id:
required: true
text:
description: Chat ID of the Roam group the message will be sent to
blocks:
required: true
description: Blocks Array of the message contents
colour:
required: true
description: Colour of the Roam notification banner
runs:
using: node20
main: index.mjs
19 changes: 15 additions & 4 deletions post-message/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ import core from "@actions/core";
try {
const apiKey = core.getInput("api-key");
const chatId = core.getInput("chat-id");
const text = core.getInput("text");
const color = core.getInput("colour");
const blocks = core.getInput("blocks");

console.log(blocks);

const body = JSON.stringify({
chat: chatId,
text,
color,
blocks: JSON.parse(blocks)
});

const response = await fetch("https://api.ro.am/v0/chat.post", {
method: "POST",
headers: {
Expand All @@ -17,12 +22,18 @@ 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);
}
}