Skip to content

Commit

Permalink
updates for devsite and workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kameshsampath committed Jul 1, 2020
1 parent 9395cc3 commit a2db1a3
Show file tree
Hide file tree
Showing 12 changed files with 203 additions and 48 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
59 changes: 38 additions & 21 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,43 @@ name: docs

on:
push:
branches:
- master
paths:
- 'documentation/**'
- '*.yml'

branches:
- master
env:
SITE_DIR: "gh-pages"
jobs:
build-and-publish:
runs-on: ubuntu-18.04
build_site:
name: "Build site with Antora"
runs-on: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: "Generate site using antora site action"
uses: kameshsampath/antora-site-action@master
with:
antora_playbook: site.yml
- name: "Upload generated site"
uses: actions/[email protected]
with:
name: site
path: "${{ github.workspace }}/${{ env.SITE_DIR }}"
deploy_site:
runs-on: [ubuntu-latest]
needs: [build_site]
name: "Deploy GitHub Pages"
steps:
- name: Checkout project
uses: actions/checkout@v2
- name: Run antora
uses: docker://antora/antora:2.2.0
with:
args: github-pages-site.yml
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
GITHUB_TOKEN: "${{github.token}}"
FOLDER: gh-pages
BRANCH: gh-pages
COMMIT_MESSAGE: "[docs] Publishing the docs for commit(s) ${{github.sha}}"
- name: Checkout
uses: actions/checkout@v2
- name: Download generated site
uses: actions/download-artifact@v1
with:
name: site
path: "${{ github.workspace }}/${{ env.SITE_DIR }}"
- name: Deploy to GitHub Pages
uses: JamesIves/[email protected]
with:
# ACCESS_TOKEN: # optional
GITHUB_TOKEN: "${{ github.token}}"
FOLDER: "${{ env.SITE_DIR }}"
BRANCH: "gh-pages"
COMMIT_MESSAGE: "[CI] Publish Documentation for ${{ github.sha }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ istio-1.1.1
firebase*
yarn*
package*
!package.json
node_modules
.firebaserc
.firebase
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
12
21 changes: 1 addition & 20 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
Fork this repo and adjust the next content:

_In all `/*-site.yml`_

`site.title` [*]
`site.url`
`content.sources.tags`, usually as a first version you should remove this section, but you can leave it as well if you plan to use tags for releasing.
_`supplemental-ui/`_
`img/favicon.ico` to your icon. Now it uses the RHD icon.
`partials/header-content` change the *Template Tutorial* to the name of the tutorial.

_`documentation/antora.yml`_

`site.title` to [*]
`site.name` to the name of the tutorial
Check the build courseware https://redhat-scholars.github.io/build-course[documentation] on how folder structure, how to use macros and other gotchas
26 changes: 26 additions & 0 deletions dev-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
runtime:
cache_dir: ./.cache/antora

site:
title: Template Tutorial(Dev Mode)
url: http://localhost:3000/rhs-build-course/index.html
start_page: template-tutorial::index.adoc

content:
sources:
- url: .
branches: HEAD
start_path: documentation
asciidoc:
attributes:
title: Template Tutorial(Dev Mode)
extensions:
- ./lib/remote-include-processor.js
- ./lib/tab-block.js
ui:
bundle:
url: https://github.com/redhat-scholars/course-ui/releases/download/v0.1.1/ui-bundle.zip
snapshot: true
supplemental_files: ./supplemental-ui
output:
dir: ./gh-pages
6 changes: 3 additions & 3 deletions documentation/antora.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: template-tutorial
title: Template Tutorial
version: '1.0.x'
version: master
nav:
- modules/ROOT/nav.adoc
- modules/ROOT/nav.adoc

start_page: ROOT:index.adoc
start_page: ROOT:index.adoc
3 changes: 0 additions & 3 deletions generate_docs.sh

This file was deleted.

78 changes: 78 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*jshint esversion: 6 */

import { series, watch } from "gulp";
import { remove } from "fs-extra";
import { readFileSync } from "fs";
import {load as yamlLoad} from "yaml-js";
import generator from "@antora/site-generator-default";
import browserSync from "browser-sync";

const filename = "dev-site.yml";
const server = browserSync.create();
const args = ["--playbook", filename];

//Watch Paths
function watchGlobs() {
let json_content = readFileSync(`${__dirname}/${filename}`, "UTF-8");
let yaml_content = yamlLoad(json_content);
let dirs = yaml_content.content.sources.map(source => [
`${source.url}/**/**.yml`,
`${source.url}/**/**.adoc`,
`${source.url}/**/**.hbs`
]);
dirs.push(["dev-site.yml"]);
dirs = [].concat(...dirs);
//console.log(dirs);
return dirs;
}

const siteWatch = () => watch(watchGlobs(), series(build, reload));

const removeSite = done => remove("gh-pages", done);
const removeCache = done => remove(".cache", done);

function build(done) {
generator(args, process.env)
.then(() => {
done();
})
.catch(err => {
console.log(err);
done();
});
}

function workshopSite(done){
generator(["--pull", "--stacktrace","--playbook","workshop-site.yaml"], process.env)
.then(() => {
done();
})
.catch(err => {
console.log(err);
done();
});
}

function reload(done) {
server.reload();
done();
}

function serve(done) {
server.init({
server: {
baseDir: "./gh-pages"
}
});
done();
}

const _build = build;
export { _build as build };
const _clean = series(removeSite, removeCache);
export { _clean as clean };
const _default = series(_clean, build, serve, siteWatch);
export { _default as default };
//build workshop docs
const _wsite = series(_clean, workshopSite);
export { _wsite as workshopSite };
39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "rhs-openshift-admins-devops",
"description": "OpenShift Admins Devops Course Documentation Site",
"homepage": "https://redhat-scholars.github.io/openshift-admins-devops",
"author": {
"email": "[email protected]",
"name": "Kamesh Sampath",
"url": "https://twitter.com/@kamesh_sampath"
},
"dependencies": {
"@antora/cli": "^2.3.1",
"@antora/site-generator-default": "^2.3.1",
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/polyfill": "^7.4.4",
"@babel/preset-env": "^7.5.5",
"@babel/register": "^7.5.5",
"browser-sync": "^2.26.7",
"fs-extra": "^8.1.0",
"gulp": "^4.0.0",
"yaml-js": "^0.2.3"
},
"devDependencies": {},
"scripts": {
"dev": "gulp",
"clean": "gulp clean",
"workshop": "gulp workshopSite"
},
"repository": {
"type": "git",
"url": "git+https://github.com/redhat-scholars/openshift-admins-devops.git"
},
"license": "Apache-2.0",
"babel": {
"presets": [
"@babel/preset-env"
]
}
}
6 changes: 6 additions & 0 deletions site.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

_CURR_DIR="$( cd "$(dirname "$0")" ; pwd -P )"
rm -rf $_CURR_DIR/gh-pages $_CURR_DIR/.cache

antora --pull --stacktrace site.yml
3 changes: 2 additions & 1 deletion site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ runtime:
cache_dir: ./.cache/antora

site:
title: RedHat Scholars::Course Template
title: Template Tutorial
url: https://redhat-scholars.github.io/course-template

content:
sources:
- url: ./
start_path: documentation
start_page: template-tutorial::index.adoc

asciidoc:
attributes:
Expand Down

0 comments on commit a2db1a3

Please sign in to comment.