Skip to content
Merged
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
11 changes: 11 additions & 0 deletions docs-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ export default {
},
],

// Single pages to fetch from external repos (not versioned).
githubSinglePageSources: [
{
owner: "prometheus",
repo: "governance",
branch: "main",
filePath: "GOVERNANCE.md",
outputPath: "governance/GOVERNANCE.md",
},
],

// Long-term support versions configuration.
ltsVersions: {
prometheus: ["3.5", "3.13"],
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Prometheus was initially started privately by
[Julius Volz](http://juliusv.com). The majority of its
initial development was sponsored by [SoundCloud](https://soundcloud.com).

It's now maintained and extended by a wide range of [companies](https://prometheus.devstats.cncf.io/d/5/companies-table?orgId=1) and [individuals](https://prometheus.io/governance).
It's now maintained and extended by a wide range of [companies](https://prometheus.devstats.cncf.io/d/5/companies-table?orgId=1) and [individuals](https://prometheus.io/governance/).

### What license is Prometheus released under?

Expand Down
44 changes: 43 additions & 1 deletion scripts/fetch-repo-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { execSync } from "child_process";
import * as fs from "fs";
import * as path from "path";
import docsConfig from "../docs-config";
import { GithubMarkdownSource } from "../src/docs-config-types";
import {
GithubMarkdownSource,
GithubSinglePageSource,
} from "../src/docs-config-types";
import {
DocsCollection,
AllRepoVersions,
Expand Down Expand Up @@ -326,6 +329,45 @@ for (const sourceConfig of docsConfig.localMarkdownSources) {
}
}

// Fetch single-page sources from GitHub repos (not versioned).
const fetchSinglePageSource = async ({
owner,
repo,
branch,
filePath,
outputPath,
}: GithubSinglePageSource) => {
console.log(
`Fetching single page ${filePath} from ${owner}/${repo}@${branch}...`
);

const { data } = await octokit.rest.repos.getContent({
owner,
repo,
path: filePath,
ref: branch,
});

if (Array.isArray(data) || data.type !== "file" || !("content" in data)) {
throw new Error(
`Expected a single file at ${filePath} in ${owner}/${repo}, got ${Array.isArray(data) ? "directory" : data.type}`
);
}

const content = Buffer.from(data.content, "base64").toString("utf-8");
const outFile = path.join(OUTDIR, outputPath);
const outDir = path.dirname(outFile);
if (!fs.existsSync(outDir)) {
fs.mkdirSync(outDir, { recursive: true });
}
fs.writeFileSync(outFile, content);
console.log(`Wrote ${outFile}`);
};

for (const sourceConfig of docsConfig.githubSinglePageSources ?? []) {
await fetchSinglePageSource(sourceConfig);
}

// Write out the docs collection metadata object to a JSON file.
const docsCollectionFile = `${OUTDIR}/docs-collection.json`;
const allRepoVersionsFile = `${OUTDIR}/repo-versions.json`;
Expand Down
Loading
Loading