orchidhq / Orchid

Build and deploy beautiful documentation sites that grow with you
https://orchid.run
GNU General Public License v3.0
514 stars 53 forks source link

Deployment to GitHub pages not exporting themes? #274

Closed DanySK closed 5 years ago

DanySK commented 5 years ago

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 and orchidDeploy -Penv=prod as suggested here

Relevant configuration:

services:
  publications:
    stages:
      - type: ghPages
        username: 'DanySK'
        repo: 'AlchemistSimulator/latest'
        publishType: CleanBranchMaintainHistory
        dry: false

Am I missing something?

Console output:

> Task :orchidClasses

> Task :orchidDeploy
Using the following modules: 
--------------------
 * com.eden.orchid.StandardModule

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/home/danysk/.gradle/caches/modules-2/files-2.1/com.google.inject/guice/4.2.2/6dacbe18e5eaa7f6c9c36db33b42e7985e94ce77/guice-4.2.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Auto-loaded modules: 
--------------------
 * com.eden.orchid.editorial.EditorialModule
 * com.eden.orchid.impl.compilers.markdown.FlexmarkModule
 * com.eden.orchid.impl.compilers.pebble.PebbleModule
 * com.eden.orchid.kotlindoc.KotlindocModule
 * com.eden.orchid.languages.highlighter.SyntaxHighlighterModule
 * com.eden.orchid.plugindocs.PluginDocsModule
 * com.eden.orchid.search.SearchModule
 * com.eden.orchid.wiki.WikiModule

Flag values: 
--------------------
-adminTheme: Default
-baseUrl: /
-defaultTemplateExtension: peb
-dest: /home/danysk/Dropbox/Workspaces/Alchemist/alchemist/build/docs/orchid
-dryDeploy: false
-environment: debug
-githubToken: [HIDDEN]
-kotlindocClasspath: [HIDDEN]
-logLevel: VERBOSE
-port: 8080
-src: /home/danysk/Dropbox/Workspaces/Alchemist/alchemist/src/orchid/resources
-task: deploy
-theme: Editorial
-version: 7.0.2-devlx+b4aa6660

[INFO] Orchid: Running Orchid version 0.16.10, site version 7.0.2-devlx+b4aa6660 in debug environment
[INFO] TaskServiceImpl: Build Starting...
[INFO] GeneratorServiceImpl: Indexing [10000: assets]
[INFO] GeneratorServiceImpl: Indexing [1000: home]
[INFO] GeneratorServiceImpl: Indexing [1000: kotlindoc]
[INFO] GeneratorServiceImpl: Indexing [1000: wiki]
[INFO] GeneratorServiceImpl: Indexing [11: sitemap]
[INFO] GeneratorServiceImpl: Indexing [10: indices]
[INFO] GeneratorServiceImpl: Generating [10000: assets]
[INFO] GeneratorServiceImpl: Generating [1000: home]
[INFO] GeneratorServiceImpl: Generating [1000: kotlindoc]
[INFO] GeneratorServiceImpl: Generating [1000: wiki]
[INFO] GeneratorServiceImpl: Generating [11: sitemap]
[INFO] GeneratorServiceImpl: Generating [10: indices]

Build Metrics: 
┌───────────┬────────────┬───────────────┬─────────────────┬───────────────────────────┬─────────────────────────────┐
│           │ Page Count │ Indexing Time │ Generation Time │ Mean Page Generation Time │ Median Page Generation Time │
├───────────┼────────────┼───────────────┼─────────────────┼───────────────────────────┼─────────────────────────────┤
│ kotlindoc │    504     │   10s 364ms   │    5s 179ms     │           10ms            │             8ms             │
├───────────┼────────────┼───────────────┼─────────────────┼───────────────────────────┼─────────────────────────────┤
│      wiki │     23     │     133ms     │      130ms      │            5ms            │             5ms             │
├───────────┼────────────┼───────────────┼─────────────────┼───────────────────────────┼─────────────────────────────┤
│      home │     2      │     14ms      │      369ms      │           184ms           │            345ms            │
├───────────┼────────────┼───────────────┼─────────────────┼───────────────────────────┼─────────────────────────────┤
│     TOTAL │        529 │     10s 619ms │        5s 922ms │                      10ms │                         8ms │
└───────────┴────────────┴───────────────┴─────────────────┴───────────────────────────┴─────────────────────────────┘

Build Complete
Generated 529 pages in 16s 544ms

[WARN] Warnings:
[WARN] WikiGenerator: 
[WARN]     - Could not find wiki resource page at 'wiki/usage/grid.md'
[WARN]     - Could not find wiki resource page at 'wiki/examples/maps.md'
[WARN]     - Could not find wiki resource page at 'wiki/examples.md'
[WARN]     - Could not find wiki resource page at 'wiki/examples/scafi.md'
[WARN]     - Could not find wiki resource page at 'wiki/simulator.md'
[WARN]     - Could not find wiki resource page at 'wiki/examples/protelis.md'
[WARN]     - Could not find wiki resource page at 'wiki/usage.md'
[WARN]     - Could not find wiki resource page at 'wiki/usage/quickstart.md'
[WARN]     - Could not find wiki resource page at 'wiki/usage/maps.md'
[WARN]     - Could not find wiki resource page at 'wiki/usage/customization.md'
[WARN]     - Could not find wiki resource page at 'wiki/usage/batch.md'
[WARN]     - Could not find wiki resource page at 'wiki/usage/export.md'
[WARN]     - Could not find wiki resource page at 'wiki/readme.md'
[WARN]     - Could not find wiki resource page at 'wiki/usage/sapere.md'
[WARN]     - Could not find wiki resource page at 'wiki/usage/scafi.md'

Deploy Starting...

[DEBUG] PublicationPipeline: Publishing [100: ghPages]
[DEBUG] GithubPagesPublisher: Github Pages GIT: git clone --single-branch -b gh-pages https://github.com/AlchemistSimulator/latest.git .
Cloning into '.'...
java.nio.file.FileAlreadyExistsException: /home/danysk/Dropbox/Workspaces/Alchemist/alchemist/build/docs/gh-pages12625276874312841828
[DEBUG] GithubPagesPublisher: Github Pages GIT: git config user.name Orchid
[DEBUG] GithubPagesPublisher: Github Pages GIT: git config user.email orchid@orchid
[DEBUG] GithubPagesPublisher: Github Pages GIT: git add -A
[DEBUG] GithubPagesPublisher: Github Pages GIT: git commit -m Deploy to GitHub Pages from Orchid.
[gh-pages b8854ff] Deploy to GitHub Pages from Orchid.
 542 files changed, 15322 insertions(+), 11363 deletions(-)
 create mode 100644 Editorial/fb433f76/assets/css/editorial_main.css
 create mode 100644 Editorial/fb433f76/assets/css/editorial_orchidCustomizations.css
 create mode 100644 Editorial/fb433f76/assets/css/orchidSearch.css
 create mode 100644 Editorial/fb433f76/assets/js/editorial_main.js
 create mode 100644 Editorial/fb433f76/assets/js/editorial_orchidCustomizations.js
 create mode 100644 Editorial/fb433f76/assets/js/editorial_util.js
 create mode 100644 Editorial/fb433f76/assets/js/orchidSearch.js
[DEBUG] GithubPagesPublisher: Github Pages GIT: git push origin gh-pages:gh-pages
To https://github.com/AlchemistSimulator/latest.git
   fda1c91..b8854ff  gh-pages -> gh-pages
Deploy complete

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.4.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 1m 6s
36 actionable tasks: 33 executed, 3 up-to-date

Full configuration:

site:
  about:
    siteName: The Alchemist Simulator
    siteDescription: An extensible simulator for doing science and engineering in pervasive, bio-inspired, and aggregate computing.
Editorial:
  primaryColor: '#169C2D'
  social:
    github: 'AlchemistSimulator/Alchemist'
  menu:
    - type: link
      title: Home
      url: '/'
    - type: 'separator'
      title: 'Documentation'
    - type: 'wiki'
    - type: 'separator'
      title: 'API Docs'
    - type: "kotlindocPackages"
      title: All Packages
    - type: "kotlindocClasses"
      title: All Classes
    - type: "kotlindocClassLinks"
      includeItems: true
  extraCss:
    - 'assets/css/pygments.scss'
allPages:
  components:
    - type: 'pageContent'
    - type: "prism"
      githubTheme: 'ghcolors'
      languages:
        - kotlin
        - java
        - groovy
        - yaml
        - asciidoc
        - markdown
        - python
services:
  publications:
    stages:
      - type: ghPages
        username: 'DanySK'
        repo: 'AlchemistSimulator/latest'
        publishType: CleanBranchMaintainHistory
        dry: false

kotlindoc:
  menu:
    - type: "kotlindocClassLinks"
      includeItems: true
  pages:
    extraCss:
      - 'assets/css/orchidKotlindoc.scss'
  sourceDirs:
    - '../../../src/main/resources'
    - '../../../src/main/java'
    - '../../../src/main/kotlin'
    - '../../../alchemist-engine/src/main/resources'
    - '../../../alchemist-engine/src/main/java'
    - '../../../alchemist-engine/src/main/kotlin'
    - '../../../alchemist-grid/src/main/resources'
    - '../../../alchemist-grid/src/main/java'
    - '../../../alchemist-grid/src/main/kotlin'
    - '../../../alchemist-implementationbase/src/main/resources'
    - '../../../alchemist-implementationbase/src/main/java'
    - '../../../alchemist-implementationbase/src/main/kotlin'
    - '../../../alchemist-implementationbase/src/main/scala'
    - '../../../alchemist-incarnation-biochemistry/src/main/resources'
    - '../../../alchemist-incarnation-biochemistry/src/main/java'
    - '../../../alchemist-incarnation-biochemistry/build/generated-src/antlr/main'
    - '../../../alchemist-incarnation-biochemistry/src/main/kotlin'
    - '../../../alchemist-incarnation-biochemistry/src/main/antlr'
    - '../../../alchemist-incarnation-protelis/src/main/resources'
    - '../../../alchemist-incarnation-protelis/src/main/java'
    - '../../../alchemist-incarnation-protelis/src/main/kotlin'
    - '../../../alchemist-incarnation-sapere/src/main/resources'
    - '../../../alchemist-incarnation-sapere/src/main/java'
    - '../../../alchemist-incarnation-sapere/src/main/kotlin'
    - '../../../alchemist-incarnation-scafi/src/main/resources'
    - '../../../alchemist-incarnation-scafi/src/main/java'
    - '../../../alchemist-incarnation-scafi/src/main/kotlin'
    - '../../../alchemist-incarnation-scafi/src/main/scala'
    - '../../../alchemist-interfaces/src/main/resources'
    - '../../../alchemist-interfaces/src/main/java'
    - '../../../alchemist-interfaces/src/main/kotlin'
    - '../../../alchemist-loading/src/main/resources'
    - '../../../alchemist-loading/src/main/java'
    - '../../../alchemist-loading/src/main/kotlin'
    - '../../../alchemist-maps/src/main/resources'
    - '../../../alchemist-maps/src/main/java'
    - '../../../alchemist-maps/src/main/kotlin'
    - '../../../alchemist-projectview/src/main/resources'
    - '../../../alchemist-projectview/src/main/java'
    - '../../../alchemist-projectview/src/main/kotlin'
    - '../../../alchemist-runner/src/main/resources'
    - '../../../alchemist-runner/src/main/java'
    - '../../../alchemist-runner/src/main/kotlin'
    - '../../../alchemist-sapere-mathexp/src/main/resources'
    - '../../../alchemist-sapere-mathexp/src/main/java'
    - '../../../alchemist-sapere-mathexp/src/main/kotlin'
    - '../../../alchemist-swingui/src/main/resources'
    - '../../../alchemist-swingui/src/main/java'
    - '../../../alchemist-swingui/src/main/kotlin'
    - '../../../alchemist-time/src/main/resources'
    - '../../../alchemist-time/src/main/java'
    - '../../../alchemist-time/src/main/kotlin'
cjbrooks12 commented 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.

DanySK commented 5 years ago

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.

DanySK commented 5 years ago

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()
}