export async function getWorkflowTemplate()

in packages/github-actions-usage/src/transform.ts [66:100]


export async function getWorkflowTemplate(
	rawWorkflow: RawGithubWorkflow,
): Promise<GithubWorkflow | undefined> {
	const { path, contents, full_name } = rawWorkflow;

	const result = parseWorkflow(
		{
			name: path,
			content: contents,
		},
		new NoOperationTraceWriter(),
	);
	const errors = result.context.errors.getErrors();

	if (errors.length > 0) {
		console.error(
			`Failed to parse workflow - path:${path} repository:${full_name} errors:${errors.length}`,
			errors.map(({ message }) => message),
		);
		return undefined;
	}

	if (!result.value) {
		console.error(
			`Failed to parse workflow - path:${path} repository:${full_name} value is null`,
		);
		return undefined;
	}

	return {
		repository: rawWorkflow.full_name,
		path: rawWorkflow.path,
		template: await convertWorkflowTemplate(result.context, result.value),
	};
}