MCPcopy Create free account
hub / github.com/github/awesome-copilot / generateWorkflowsData

Function generateWorkflowsData

eng/generate-website-data.mjs:286–336  ·  view source on GitHub ↗

* Generate workflows metadata (flat .md files)

(gitDates)

Source from the content-addressed store, hash-verified

284 * Generate workflows metadata (flat .md files)
285 */
286function generateWorkflowsData(gitDates) {
287 const workflows = [];
288
289 if (!fs.existsSync(WORKFLOWS_DIR)) {
290 return {
291 items: workflows,
292 filters: {
293 triggers: [],
294 },
295 };
296 }
297
298 const workflowFiles = fs.readdirSync(WORKFLOWS_DIR).filter((file) => {
299 return file.endsWith(".md") && file !== ".gitkeep";
300 });
301
302 const allTriggers = new Set();
303
304 for (const file of workflowFiles) {
305 const filePath = path.join(WORKFLOWS_DIR, file);
306 const metadata = parseWorkflowMetadata(filePath);
307 if (!metadata) continue;
308
309 const relativePath = path
310 .relative(ROOT_FOLDER, filePath)
311 .replace(/\\/g, "/");
312
313 (metadata.triggers || []).forEach((t) => allTriggers.add(t));
314
315 const id = path.basename(file, ".md");
316 workflows.push({
317 id,
318 title: metadata.name,
319 description: metadata.description,
320 triggers: metadata.triggers || [],
321 path: relativePath,
322 lastUpdated: gitDates.get(relativePath) || null,
323 });
324 }
325
326 const sortedWorkflows = workflows.sort((a, b) =>
327 a.title.localeCompare(b.title)
328 );
329
330 return {
331 items: sortedWorkflows,
332 filters: {
333 triggers: Array.from(allTriggers).sort(),
334 },
335 };
336}
337
338/**
339 * Parse applyTo field into an array of patterns

Callers 1

mainFunction · 0.85

Calls 1

parseWorkflowMetadataFunction · 0.90

Tested by

no test coverage detected