Unverified Commit 59150d2f authored by Thomas Bouffard's avatar Thomas Bouffard Committed by GitHub
Browse files

feat: improve identification of preview environment and archive (#159)

Use the non-production navbar:
  - dedicated title and background color
  - no search

The preview bash script now allows to
  - force usage of the production navbar
  - use locally built ui-bundle
The 'title' option has been renamed into 'site-title' for consistency
parent 224a6e49
......@@ -16,13 +16,13 @@ on:
jobs:
generate_static_doc:
runs-on: ubuntu-20.04
steps:
steps:
- uses: actions/checkout@v2
- name: Generate static documentation
run: |
./build-preview.bash --branch "${{ github.event.inputs.branch }}" --component "${{ github.event.inputs.component }}" --type local --title "${{ github.event.inputs.title }}"
./build-preview.bash --branch "${{ github.event.inputs.branch }}" --component "${{ github.event.inputs.component }}" --type local --site-title "${{ github.event.inputs.title }}"
- name: Upload preview
uses: actions/upload-artifact@v2
with:
name: documentation-${{ github.event.inputs.component }}-${{ github.event.inputs.branch }}
path: build/site
\ No newline at end of file
path: build/site
......@@ -15,7 +15,6 @@ jobs:
runs-on: ubuntu-20.04
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
# GOOGLE_ANALYTICS_KEY: G-7LLM509FEH
steps:
- uses: actions/checkout@v2
if: github.event.action != 'closed'
......@@ -45,7 +44,6 @@ jobs:
dist: build/site
failOnError: true
teardown: 'true'
# GOOGLE_ANALYTICS_KEY=${{env.GOOGLE_ANALYTICS_KEY}} xxxx
build: |
./build-preview.bash --single- --pr "${{ env.PR_NUMBER }}" --site-url "${{ env.PREVIEW_URL }}" --single-branch-per-repo true
ls -lh build/site
......@@ -100,6 +100,37 @@ For more information about the `build-preview.bash` script, see later in this do
./build-preview.bash --ci false --type local --local-sources true
```
[[local-ui-bundle]]
===== Using local UI Bundle
The prebuilt UI Bundle is stored in this repository and sources are located in the https://github.com/bonitasoft/bonita-documentation-theme[bonita-documentation theme]
repository. +
If you are developing in the theme repository and want to see the resulting changes in the documentation. It provides a
fast feedback loop as you don't need to push nor commit content as the current work.
Remember that the theme repository provides a preview with mock content that make development easier. But sometimes, integration
tests are required to ensure everything is ok, especially when dealing with https://docs.antora.org/antora/2.3/playbook/site-keys/[site keys].
[NOTE]
.Repositories location
====
This requires to clone the theme repository locally is the parent folder of this project.
For instance
```
root
|
-- bonita-documentation-theme
|
-- bonitasoft.github.io
```
====
For more information about the `build-preview.bash` script, see later in this document
```bash
./build-preview.bash --ci false --type local --local-ui-bundle true
```
[[preview]]
==== Building for preview
......
......@@ -15,11 +15,13 @@ function usage() {
echo " --branch <branch-name> When not keeping a single branch by component, the name of the branch to keep"
echo " --component <component-name> When not keeping a single branch by component, the name of the component to keep"
echo " --fetch-sources <boolean> 'true': fetch documentation content sources prior building the documentation. Defaults to 'false' (on CI, fetch is always done)"
echo " --force-production-navbar <boolean> 'true': use the regular navbar instead of the preview one. Defaults to 'false'"
echo " --local-sources <boolean> 'true': use locally checkout sources in a working directory along the one of this project (useful to test local changes without push) , otherwise, use antora cache. Defaults to 'false'"
echo " --local-ui-bundle <boolean> 'true': use locally build ui bundle whose sources are in a working directory along the one of this project, otherwise, use antora cache. Defaults to 'false'"
echo " --pr <PR_NUMBER> Number of the Pull Request related to the preview (when apply). Used to display context information within the preview."
echo " --single-branch-per-repo <boolean> 'true': only keep the latest declared branch for each component, 'false': use all branches. Defaults to 'false'"
echo " --site-url <url> Custom Url of the site preview. Defaults to the original url defined in the Antora playbook."
echo " --title <string> Title of the site preview. Use generated title if not set."
echo " --site-title <string> Title of the site preview. Use generated title if not set."
echo " --type <string> If 'local' use html extension in urls to allow local file browsing"
echo " Environment configuration"
......
......@@ -22,10 +22,10 @@ function getArgument(argv, argName, isMandatory) {
const useSingleBranchPerComponent = getArgument(argv, 'single-branch-per-repo', false);
const siteUrl = getArgument(argv, 'site-url', false)
const prNumber = getArgument(argv, 'pr', false)
const siteTitle = getArgument(argv, 'title', false)
const siteTitle = getArgument(argv, 'site-title', false)
console.info(`PR: ${prNumber}`);
console.info(`Site Url: ${siteUrl}`);
console.info(`Title: ${siteTitle}`);
console.info(`Site Title: ${siteTitle}`);
const doc = yaml.load(fs.readFileSync('antora-playbook.yml', 'utf8'));
console.info('Antora Playbook source file loaded');
......@@ -73,7 +73,7 @@ else {
}
// use local sources for the documentation content repostiories
// use local sources for the documentation content repositories
const useLocalSources = getArgument(argv, 'local-sources', false)
console.info(`Use Local Sources: ${useLocalSources}`);
if (useLocalSources === 'true') {
......@@ -83,6 +83,12 @@ if (useLocalSources === 'true') {
source.url = `../${(repositoryNameForUrl(source.url))}`
});
}
// use local source for the UI bundle
const useLocalUIBundle = getArgument(argv, 'local-ui-bundle', false)
console.info(`Use Local UI Bundle: ${useLocalUIBundle}`);
if (useLocalUIBundle === 'true') {
doc.ui.bundle.url = '../bonita-documentation-theme/build/ui-bundle.zip';
}
if (siteUrl) {
......@@ -105,6 +111,17 @@ if (fetchSources === 'true') {
doc.runtime.fetch = true
}
// Set the non-production mode (custom navbar for preview)
const forceProductionNavbar = getArgument(argv, 'force-production-navbar', false)
console.info(`Force Production Navbar: ${forceProductionNavbar}`);
if (forceProductionNavbar !== 'true') {
if (!doc.site.keys) {
doc.site.keys = {};
}
doc.site.keys['non-production'] = true;
} else {
console.info('--> Force usage of production navbar');
}
console.info('Dumping yaml....');
const generatedYaml = `# Generated from 'antora-playbook.yml'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment