From 3eb756f669aadfe065d96561817aae39a8b24a75 Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Mon, 28 Feb 2022 23:18:19 -0600
Subject: [PATCH 4/7] f!html: index file

This allows linking to the artifacts from the last successful build, which
itself allows *not* rebuilding when sources haven't changed.

ci-os-only: html
---
 src/tools/ci/copy-changed-docs | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/tools/ci/copy-changed-docs b/src/tools/ci/copy-changed-docs
index 0a942838f5c..ca6214d40a6 100755
--- a/src/tools/ci/copy-changed-docs
+++ b/src/tools/ci/copy-changed-docs
@@ -7,10 +7,19 @@ outdir=html_docs
 mkdir "$outdir"
 cp new-docs/src/sgml/html/*.css new-docs/src/sgml/html/*.svg "$outdir/"
 
+# The index is useful to allow a static link to all changed docs
+# https://api.cirrus-ci.com/v1/artifact/github/USERNAME/postgres/Documentation/html_docs/html_docs/00-doc.html?branch=BRANCH
+index="$outdir/00-doc.html"
+echo "<html><head><title>Index of changed docs</title></head><body><ul>" >"$index"
+
 changed=`git diff --no-index --name-only old-docs/src/sgml/html new-docs/src/sgml/html` ||
 	[ $? -eq 1 ]
 
 for f in $changed
 do
 	cp "$f" "$outdir"
-done
+	fn=${f##*/}
+	echo "<li><a href='$fn'>$fn</a>"
+done >>"$index"
+
+echo "</ul></body></html>" >>"$index"
-- 
2.17.1

