Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 3x 3x 3x 3x 3x 3x 3x 3x 3x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 4x 2x 2x 2x 3x 4x 2x 2x 4x 2x 2x 2x 2x 4x 1x | import * as core from '@actions/core';
import * as github from '@actions/github';
import { CreateEvent, RequestEventParams } from './event';
/**
* Main function that runs when the GitHub Action is triggered
*/
export const run = async (): Promise<void> => {
try {
// Get inputs from the GitHub Action
const title = core.getInput('title', { required: true });
const text = core.getInput('text', { required: true });
const alertType = core.getInput('alertType');
const priority = core.getInput('priority');
const host = core.getInput('host');
const tags = core.getInput('tags') ? core.getInput('tags').split(',').map(tag => tag.trim()) : [];
const aggregationKey = core.getInput('aggregationKey');
const sourceTypeName = core.getInput('sourceTypeName');
// Add GitHub context to tags if specified
const includeGitHubContext = core.getBooleanInput('includeGitHubContext');
if (includeGitHubContext) {
const { repo, owner } = github.context.repo;
tags.push(
`repo:${repo}`,
`owner:${owner}`,
`workflow:${github.context.workflow}`,
`ref:${github.context.ref}`,
`sha:${github.context.sha}`
);
}
// Create event request
const request: RequestEventParams = {
title,
text,
alertType,
priority,
host,
tags,
sourceTypeName
};
// Send event to Datadog
const results = await CreateEvent({
requests: [request],
aggregationKey
});
// Set outputs
if (results && results.length > 0) {
core.setOutput('eventUrl', results[0].eventUrl);
core.setOutput('eventId', results[0].response.event?.id?.toString());
}
core.info(`Successfully sent event to Datadog: ${title}`);
if (results[0].eventUrl) {
core.info(`Event URL: ${results[0].eventUrl}`);
}
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
} else {
core.setFailed('An unknown error occurred');
}
}
}
run().catch(error => {
console.error('Unhandled error:', error);
process.exit(1);
});
|