openhab / openhab-docs

This repository contains the documentation for openHAB.
https://www.openhab.org/docs/
Other
271 stars 689 forks source link

[CI/CD] - The preview link created by the pipeline point to an empty page #2269

Closed pgfeller closed 6 months ago

pgfeller commented 7 months ago

A preview of the documentation is built for each contribution to the documentation repository to check the result. The preview is done using Netlify. Until the changes done in PR2218 the link pointed to the repository README file (not the documentation). The documentation is (and was) available under /docs.

➡️ The preview link should open the documentation & not show a 404 nor the readme

This should be achievable using configuration of the pipeline: Netlify file based configuration

⚠️We have to be careful, that this will not break the integrated OH web page build - therefore the fix should be combined with the issue/enhancement #455 from the website repo to enable us to be confident that our .toml redirect configuration has no negative impact.

@stefan-hoehn Please assign this issue to me - I'll have a look (as discussed).

pgfeller commented 7 months ago

@stefan-hoehn

At a first glance the fix looks trivial - I tried it in my local fork; see (closed) PR above - it redirects to https://deploy-preview-3--pgfeller.netlify.app/docs/ as desired. I need to have a look into #455 once I created the PR here.

To add the possibility to select an arbitrary branch and to remove the .toml in case looks not too difficult at first glance:

prepare-docs.rb:

# This will clone https://github.com/openhab/openhab-docs
# and migrate content into the website with some changes

require "fileutils"
require "net/http"
require "uri"
require "rexml/document"

$docs_repo = "https://github.com/openhab/openhab-docs"
$docs_repo_root = $docs_repo + "/blob/main"
$docs_repo_branch = "final"
$addons_repo_branch = "main"
$version = nil

$ignore_addons = ['transport.modbus', 'transport.feed', 'javasound', 'webaudio', 'oh2']

if ENV["OH_DOCS_VERSION"] then
    puts ">>> Generating docs for version #{ENV["OH_DOCS_VERSION"]}"
    $version = ENV["OH_DOCS_VERSION"]
    $version += ".0" if $version.split(".").length == 2
end

if (ARGV[0] && ARGV[0] == "--no-clone" && Dir.exists?(".vuepress/openhab-docs")) then
    puts ">>> Re-using existing clone"
else
    puts ">>> Deleting .vuepress/openhab-docs if existing..."
    FileUtils.rm_rf(".vuepress/openhab-docs")

    puts ">>> Cloning openhab-docs"
    `git clone --depth 1 --branch #{$version ? $version : $docs_repo_branch} https://github.com/openhab/openhab-docs .vuepress/openhab-docs`
end