Skip to content

Commit

Permalink
remove some debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Lifeismana committed Jun 16, 2024
1 parent 563ce8c commit bd7b5c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Steam-Watcher

Watches steam for app updates and sends configured webhooks.

## TODO

- Hot reload config
- Only send webhooks when the buildid changes
Watches steam for app updates and sends configured webhooks.
29 changes: 15 additions & 14 deletions src/bot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ await cache.init();

const sendWebhook = async (data, appid) => {
try {
console.debug(data);
let response;
switch (data.type) {
case "discord":
await fetch(data.url, {
response = await fetch(data.url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand All @@ -27,23 +27,24 @@ const sendWebhook = async (data, appid) => {
});
break;
case "github":
console.debug(
await fetch(`https://api.github.com/repos/${data.repo}/actions/workflows/${data.workflow_id}/dispatches`, {
method: "POST",
headers: {
Accept: "application/vnd.github.everest-preview+json",
"Content-Type": "application/json",
Authorization: `Bearer ${data.access_token}`,
},
body: JSON.stringify({
ref: data.branch || "main",
}),
response = await fetch(`https://api.github.com/repos/${data.repo}/actions/workflows/${data.workflow_id}/dispatches`, {
method: "POST",
headers: {
Accept: "application/vnd.github.everest-preview+json",
"Content-Type": "application/json",
Authorization: `Bearer ${data.access_token}`,
},
body: JSON.stringify({
ref: data.branch || "main",
}),
);
});
break;
default:
console.log("Unknown webhook type");
}
if (response.status < 200 || response.status >= 300) {
console.error(`Failed to send webhook: ${response.status} ${response.statusText} ${response.url}`);
}
} catch (err) {
console.error(err);
}
Expand Down

0 comments on commit bd7b5c2

Please sign in to comment.