Closed DanySK closed 5 years ago
It looks like the base URL is not set, so relative URLs are searching in https://alchemistsimulator.github.io
for stylesheets, etc. instead of https://alchemistsimulator.github.io/latest/
.
Try adding the base URL to your build.gradle
, which will be prepended to all generated links and should fix the problem:
orchid {
baseUrl = "https://alchemistsimulator.github.io/latest/"
}
It works on orchidServe
because Orchid will change that base URL to point to localhost when serving locally.
I see. I'm going to try and report results, thanks.
I'd like to deploy the stable site on https://alchemistsimulator.github.io
and the latest beta site on https://alchemistsimulator.github.io/latest/
. To do so, I need to change config.yml
dynamically from build.gradle.kts
, I guess... Or is there a way to select a subset of stages to deploy? I see OrchidPluginExtension
has a flag dryDeploy
, but I cannot understand how to apply it to a subset of deploys.
That was the problem indeed. Thanks!
I also sorted out the different baseUrl, and made sure that I don't accidentally roll-back the website. I'm sharing the solution.
orchid {
theme = "Editorial"
// Feed arguments to Kdoc
val projects: Collection<Project> = listOf(project) + subprojects
val paths = projects.map { it.sourceSets["main"].compileClasspath.asPath }
args = listOf("--kotlindocClasspath") + paths.joinToString(File.pathSeparator)
// Determine whether it's a deployment or a dry run
val uriEnd = if ("""\d+(\.\d+){2}""".toRegex().matches(rootProject.version.toString())) "" else "latest/"
baseUrl = "https://alchemistsimulator.github.io/$uriEnd"
// Fetch the latest version of the website, if this one is more recent enable deploy
val versionRegex = """.*Currently\s*(.+)\.\s*Created""".toRegex()
val matchedVersions: List<String> = try {
URL(baseUrl).openConnection().getInputStream().use { stream ->
stream.bufferedReader().lineSequence()
.flatMap { line -> versionRegex.find(line)?.groupValues?.last()?.let { sequenceOf(it) } ?: emptySequence() }
.toList()
}
} catch (e: Exception) { emptyList() }
if (matchedVersions.isEmpty()) {
println("Unable to fetch the current site version from $baseUrl. Orchid deployment set as dry run.")
}
if (matchedVersions.size > 1) {
println("Multiple site versions fetched from $baseUrl: $matchedVersions. Orchid deployment set as dry run.")
}
val shouldDeploy = matchedVersions
.takeIf { it.size == 1 }
?.first()
?.let { rootProject.version.toString() > it }
?: false
dryDeploy = shouldDeploy.not().toString()
}
I tried to deploy an Orchid website on GitHub pages. The website uses Editorial, and works perfectly locally with the orchidServe task.
However, once deployed on GitHub Pages, the styling is lost: https://alchemistsimulator.github.io/latest/
I tried both
orchidDeploy
andorchidDeploy -Penv=prod
as suggested hereRelevant configuration:
Am I missing something?
Console output:
Full configuration: