-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
36 lines (33 loc) · 1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { getInput, setFailed } from "@actions/core";
import fetch from "node-fetch";
try {
const projectId = getInput("posthog-project-id");
const posthogToken = getInput("posthog-token");
const posthogAPIHost = getInput("posthog-api-host");
const annotationMessage = getInput("annotation-message");
const body = {
content: annotationMessage,
scope: "project",
date_marker: new Date().toISOString(),
creation_type: "GIT"
};
// API docs at https://posthog.com/docs/api/annotations#post-api-projects-project_id-annotations
fetch(`${posthogAPIHost}/api/projects/${projectId}/annotations/`, {
method: "post",
body: JSON.stringify(body),
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${posthogToken}`,
},
})
.then((response) => {
response.json().then((data) => {
console.log("success", data);
});
})
.catch((error) => {
console.error("error", error);
});
} catch (error) {
setFailed(error.message);
}