Skip to content
Open
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
21 changes: 21 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
name: Mixpanel Annotate
description: Creates a Mixpanel Annotation
inputs:
description:
description: The text that will be shown when looking at the annotation
required: true
date:
description: Date of the Annotation (format: YYYY-MM-DD HH:mm:ss)
required: false
project_id:
description: Mixpanel Project ID
required: true
service_account_username:
description: Mixpanel Service Account Username
required: true
service_account_password:
description: Mixpanel Service Account Password
required: true
outputs:
description:
description: The text that will be shown when looking at the annotation
date:
description: Date of the Annotation (format: YYYY-MM-DD HH:mm:ss)
id:
description: Annotation ID
runs:
using: 'node16'
main: 'dist/index.js'
36 changes: 35 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
const core = require('@actions/core');

const { HttpClient } = require('@actions/http-client');
const { BasicCredentialHandler } = require('@actions/http-client/lib/auth');

async function run() {
var description = core.getInput('description');
var date = core.getInput('date');
const project_id = core.getInput('project_id');
const service_account_username = core.getInput('service_account_username');
const service_account_password = core.getInput('service_account_password');

const http = new HttpClient('http', [
new BasicCredentialHandler(
service_account_username, service_account_password,
),
]);

const res = await http.post(
`https://mixpanel.com/api/app/projects/${project_id}/annotations`,
JSON.stringify({
'description': description,
'date': date,
}),
{
'Accept': 'application/json',
'Content-Type': 'application/json',
}
);

const obj = JSON.parse(await res.readBody());
const { status, error } = obj;

if (status === 'error') return core.setFailed(error);

var { description, date, id } = obj;
core.setOutput('description', description);
core.setOutput('date', date);
core.setOutput('id', id);
}

run();
Loading