Files
kener/scripts/generate-readme.js
Kyle Affolder 28a72a3592 fix: README generation
Changed from trying to use artifacts and the GHA workflow failing to now using a simple `BUILD_VERSION` repository variable and automatically updating that when the `build-and-push-to-registries` workflow succeeds.

Other changes include:

* Added `workflow_run` trigger to `generate-readme.yml` so when that workflow recognizes the “Publish Docker Image to Registries” workflow runs and succeeds, it will automatically run the `generate-readme.yml` workflow (since a new Docker release will require Docker image variants table in README.md to have versioning updated)
* Generate major and major-minor versions from the `BUILD_VERSION` repository variable (more efficient than storing three separate variables from the `build-and-push-to-registries` workflow job)
2025-02-11 15:39:42 -05:00

32 lines
990 B
JavaScript

import fs from "fs";
import Mustache from "mustache";
import dotenv from "dotenv";
import { fileURLToPath } from "url";
import path from "path";
// Load environment variables from .env file
dotenv.config();
// Resolve paths correctly in ES modules
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Load the template
const templatePath = path.resolve(__dirname, "../README.template.md");
const template = fs.readFileSync(templatePath, "utf-8");
// Load environment variables and provide default values
const data = {
kener_full_version: process.env.BUILD_FULL_VERSION || "N/A",
kener_major_version: process.env.BUILD_MAJOR_VERSION || "N/A",
kener_major_minor_version: process.env.BUILD_MAJOR_MINOR_VERSION || "N/A",
};
// Render README.md
const output = Mustache.render(template, data);
// Write to README.md
fs.writeFileSync(path.resolve(__dirname, "../README.md"), output);
console.log("✅ README.md generated successfully!");