From 4d50163c8ccfc48b4abb7c8c2d648d39756c4de6 Mon Sep 17 00:00:00 2001 From: gotbadger Date: Mon, 15 Jul 2024 14:22:25 +0100 Subject: [PATCH] ci: provide version info in docs --- docs/_data/github.js | 21 +++++++++++++++++++++ docs/version.json.njk | 9 +++++++++ 2 files changed, 30 insertions(+) create mode 100644 docs/version.json.njk diff --git a/docs/_data/github.js b/docs/_data/github.js index 064c2f841..61a50c82e 100644 --- a/docs/_data/github.js +++ b/docs/_data/github.js @@ -6,6 +6,7 @@ module.exports = async function () { // type: "json", // }); let release = {} + let rulesRelease = {} try { release = await EleventyFetch( "https://api.github.com/repos/bearer/bearer/releases/latest", @@ -16,6 +17,23 @@ module.exports = async function () { ) } catch (err) { console.log("Could not fetch release") + if (process.env.ELEVENTY_PRODUCTION) { + throw err + } + } + try { + rulesRelease = await EleventyFetch( + "https://api.github.com/repos/bearer/bearer-rules/releases/latest", + { + duration: "60m", + type: "json", + }, + ) + } catch (err) { + console.log("Could not fetch rulesRelease") + if (process.env.ELEVENTY_PRODUCTION) { + throw err + } } return { // stargazers: repo.stargazers_count, @@ -23,5 +41,8 @@ module.exports = async function () { name: release.tag_name || "DEV", url: release.html_url || "/", }, + rules: { + name: rulesRelease.tag_name || "DEV_RULES", + }, } } diff --git a/docs/version.json.njk b/docs/version.json.njk new file mode 100644 index 000000000..57ae4b6d2 --- /dev/null +++ b/docs/version.json.njk @@ -0,0 +1,9 @@ +--- +permalink: '/version.json' +eleventyExcludeFromCollections: true +layout: false +--- +{ + "binary": "{{ github.release.name }}", + "rules": "{{ github.rules.name }}" +}