Skip to content

Commit fbcf7ca

Browse files
ci: new github action workflow to generate static web pages using hugo (#200)
Signed-off-by: Jeffrey Tang <[email protected]>
1 parent 2a66fe9 commit fbcf7ca

File tree

8 files changed

+227
-16
lines changed

8 files changed

+227
-16
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
##
2+
# Copyright (C) 2023-2024 Hedera Hashgraph, LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
##
16+
17+
# Sample workflow for building and deploying a Hugo site to GitHub Pages
18+
name: Deploy Hugo site to Pages
19+
20+
on:
21+
# Runs on pushes targeting the default branch
22+
push:
23+
branches:
24+
- 00120-D-hugo-pipeline
25+
26+
# Allows you to run this workflow manually from the Actions tab
27+
workflow_dispatch:
28+
29+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
30+
permissions:
31+
contents: read
32+
pages: write
33+
id-token: write
34+
35+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
36+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
37+
concurrency:
38+
group: "pages"
39+
cancel-in-progress: false
40+
41+
# Default to bash
42+
defaults:
43+
run:
44+
shell: bash
45+
46+
jobs:
47+
# Build job
48+
build:
49+
runs-on: [self-hosted, Linux, medium, ephemeral]
50+
51+
steps:
52+
- name: Setup Hugo
53+
uses: peaceiris/actions-hugo@v2
54+
with:
55+
hugo-version: '0.124.1'
56+
57+
- name: Checkout Code
58+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
59+
with:
60+
fetch-depth: 0
61+
62+
- name: Setup Node
63+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
64+
with:
65+
node-version: 20
66+
67+
- name: Setup Pages
68+
id: pages
69+
uses: actions/configure-pages@v4
70+
with:
71+
enablement: true
72+
73+
- name: Install jsdoc
74+
run: |
75+
cd docs
76+
npm i -g jsdoc
77+
jsdoc --version
78+
jsdoc -c jsdoc.conf.json
79+
cd -
80+
81+
- name: Install jsdoc-to-markdown
82+
run: |
83+
cd docs
84+
npm i -g jsdoc-to-markdown
85+
jsdoc2md --version
86+
./generate_md.sh
87+
cd -
88+
89+
- name: Copy existing documentation
90+
run: |
91+
mkdir -p docs/content/Developer
92+
cp DEV.md docs/content/Developer/DEV.md
93+
mkdir -p docs/content/User
94+
cp README.md docs/content/User/README.md
95+
96+
- name: Build with Hugo
97+
env:
98+
# For maximum backward compatibility with Hugo modules
99+
HUGO_ENVIRONMENT: production
100+
HUGO_ENV: production
101+
run: |
102+
cd docs
103+
echo "base_url ${{ steps.pages.outputs.base_url }}"
104+
echo "origin ${{ steps.pages.outputs.origin }}"
105+
echo "host ${{ steps.pages.outputs.host }}"
106+
echo "base_path ${{ steps.pages.outputs.base_path }}"
107+
mkdir -p themes/hugo-geekdoc
108+
curl -L https://github.com/thegeeklab/hugo-geekdoc/releases/latest/download/hugo-geekdoc.tar.gz | tar -xz -C themes/hugo-geekdoc/ --strip-components=1
109+
ls -ltr
110+
hugo version
111+
hugo config
112+
hugo \
113+
--gc \
114+
--config hugo.toml \
115+
--minify \
116+
--baseURL "${{ steps.pages.outputs.base_url }}/"
117+
118+
- name: Upload artifact
119+
uses: actions/upload-pages-artifact@v3
120+
with:
121+
path: ./docs/public
122+
123+
# Deployment job
124+
deploy:
125+
environment:
126+
name: github-pages
127+
url: ${{ steps.deployment.outputs.page_url }}
128+
runs-on: [self-hosted, Linux, medium, ephemeral]
129+
needs: build
130+
steps:
131+
- name: Deploy to GitHub Pages
132+
id: deployment
133+
uses: actions/deploy-pages@v4

docs/data/menu/main.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
main:
3+
- name: User
4+
ref: "/User/README.md"
5+
- name: Developer
6+
ref: "/Developer/DEV.md"
7+
- name: Classes
8+
ref: "/solo/static/Classes/index.html"
9+
external: true

docs/data/menu/more.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#available icons: https://github.com/thegeeklab/hugo-geekdoc/tree/master/src/icons
2+
---
3+
more:
4+
- name: Hedera Hashgraph
5+
ref: "https://hedera.com/"
6+
external: true
7+
- name: "View Source"
8+
ref: "https://github.com/hashgraph/solo/issues"
9+
external: true
10+
icon: "gdoc_github"
11+

docs/generate_md.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
# find javascript files
4+
FIND_CMD=$(find ../src -name "*js")
5+
6+
# save result to array
7+
FILES=($FIND_CMD)
8+
9+
mkdir -p content/Classes
10+
11+
for i in "${FILES[@]}"
12+
do
13+
# echo $i
14+
# extract base file name from path, remove path and extension
15+
BASENAME=$(basename $i .js)
16+
jsdoc2md --no-cache -c jsdoc2md.conf.json $i > ./content/Classes/$BASENAME.md
17+
done

docs/hugo.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
baseURL = 'https://hashgraph.github.io/solo'
2+
languageCode = 'en-us'
3+
title = 'Solo Documentation'
4+
theme = "hugo-geekdoc"
5+
6+
# Geekdoc required configuration
7+
pygmentsUseClasses = true
8+
pygmentsCodeFences = true
9+
disablePathToLower = true
10+
11+
enableGitInfo = true
12+
13+
14+
# Required if you want to render robots.txt template
15+
enableRobotsTXT = true
16+
17+
# Needed for mermaid shortcodes
18+
[markup]
19+
[markup.goldmark.renderer]
20+
# Needed for mermaid shortcode
21+
unsafe = true
22+
[markup.tableOfContents]
23+
startLevel = 1
24+
endLevel = 9
25+
26+
[markup.highlight]
27+
style = "vs"
28+
29+
[taxonomies]
30+
tag = "tags"
31+
32+
[params]
33+
# (Optional, default false) Render menu from data file in 'data/menu/main.yaml'.
34+
# See also https://geekdocs.de/usage/menus/#bundle-menu.
35+
geekdocMenuBundle = true

docs/jsdoc.conf.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"source": {
3+
"include": [ "../src" ],
4+
"includePattern": ".+\\.(js(doc|x)?|mjs)$"
5+
},
6+
"sourceType": "module",
7+
"opts": {
8+
"recurse": true,
9+
"destination": "public/static/Classes"
10+
}
11+
}
12+

docs/jsdoc2md.conf.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"source": {
3+
"includePattern": ".+\\.(js(doc|x)?|mjs)$"
4+
},
5+
"sourceType": "module",
6+
"opts": {
7+
"recurse": true
8+
}
9+
}
10+

src/core/account_manager.mjs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,6 @@ const REASON_FAILED_TO_CREATE_K8S_S_KEY = 'failed to create k8s scrt key'
4040
const FULFILLED = 'fulfilled'
4141
const REJECTED = 'rejected'
4242

43-
/**
44-
* Copyright (C) 2024 Hedera Hashgraph, LLC
45-
*
46-
* Licensed under the Apache License, Version 2.0 (the ""License"");
47-
* you may not use this file except in compliance with the License.
48-
* You may obtain a copy of the License at
49-
*
50-
* http://www.apache.org/licenses/LICENSE-2.0
51-
*
52-
* Unless required by applicable law or agreed to in writing, software
53-
* distributed under the License is distributed on an ""AS IS"" BASIS,
54-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
55-
* See the License for the specific language governing permissions and
56-
* limitations under the License.
57-
*
58-
*/
5943
export class AccountManager {
6044
/**
6145
* creates a new AccountManager instance

0 commit comments

Comments
 (0)