Skip to content

Commit 141cae7

Browse files
authored
docs: add site for hosting docs on github pages (#204)
Adds a static site generation using Hugo, and deployed to GitHub pages (googleapis.github.io/genai-toolbox).
1 parent 6162780 commit 141cae7

23 files changed

+1476
-0
lines changed

.github/workflows/docs_deploy.yaml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: "docs"
16+
17+
permissions:
18+
contents: write
19+
20+
on:
21+
push:
22+
branches:
23+
- main
24+
paths:
25+
- 'docs/**'
26+
- 'github/workflows/docs**'
27+
- '.hugo'
28+
29+
# Allow triggering manually.
30+
workflow_dispatch:
31+
32+
jobs:
33+
deploy:
34+
runs-on: ubuntu-22.04
35+
defaults:
36+
run:
37+
working-directory: .hugo
38+
concurrency:
39+
group: ${{ github.workflow }}-${{ github.ref }}
40+
cancel-in-progress: true
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
45+
46+
- name: Setup Hugo
47+
uses: peaceiris/actions-hugo@v3
48+
with:
49+
hugo-version: "latest"
50+
extended: true
51+
52+
- name: Setup Node
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: "22"
56+
57+
- name: Cache dependencies
58+
uses: actions/cache@v4
59+
with:
60+
path: ~/.npm
61+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
62+
restore-keys: |
63+
${{ runner.os }}-node-
64+
65+
- run: npm ci
66+
- run: hugo --minify
67+
env:
68+
# HUGO_BASEURL: https://${{ github.repository_owner }}.github.io/${{ github.repository }}
69+
# While private, GitHub uses an obfuscated url instead:
70+
HUGO_BASEURL: https://vigilant-guacamole-plnwrm9.pages.github.io/
71+
HUGO_RELATIVEURLS: false
72+
73+
- name: Deploy
74+
uses: peaceiris/actions-gh-pages@v4
75+
with:
76+
github_token: ${{ secrets.GITHUB_TOKEN }}
77+
publish_dir: .hugo/public
78+
# Do not delete previews on each production deploy.
79+
# CSS or JS changes will require manual clean-up.
80+
keep_files: true
81+
commit_message: "deploy: ${{ github.event.head_commit.message }}"
+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: "docs"
16+
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
21+
# This Workflow depends on 'github.event.number',
22+
# not compatible with branch or manual triggers.
23+
on:
24+
pull_request:
25+
types:
26+
- closed
27+
28+
jobs:
29+
clean:
30+
if: ${{ !github.event.pull_request.head.repo.fork }}
31+
runs-on: ubuntu-24.04
32+
concurrency:
33+
# Shared concurrency group wih preview staging.
34+
group: "preview-${{ github.event.number }}"
35+
cancel-in-progress: true
36+
steps:
37+
- uses: actions/checkout@v4
38+
with:
39+
ref: gh-pages
40+
41+
- name: Remove Preview
42+
run: |
43+
rm -Rf ./previews/PR-${{ github.event.number }}
44+
git config user.name 'github-actions[bot]'
45+
git config user.email 'github-actions[bot]@users.noreply.github.com'
46+
git add -u previews/PR-${{ github.event.number }}
47+
git commit --message "cleanup: previews/PR-${{ github.event.number }}"
48+
git push
49+
50+
- name: Comment
51+
uses: actions/github-script@v7
52+
with:
53+
script: |
54+
github.rest.issues.createComment({
55+
issue_number: context.payload.number,
56+
owner: context.repo.owner,
57+
repo: context.repo.repo,
58+
body: "🧨 Preview deployments removed."
59+
})
+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: "docs"
16+
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
21+
# This Workflow depends on 'github.event.number',
22+
# not compatible with branch or manual triggers.
23+
on:
24+
pull_request:
25+
# Sync with github_actions_preview_fallback.yml on.pull_request.paths-ignore
26+
paths:
27+
- 'docs/**'
28+
- 'github/workflows/docs**'
29+
- '.hugo'
30+
31+
jobs:
32+
preview:
33+
runs-on: ubuntu-24.04
34+
defaults:
35+
run:
36+
working-directory: .hugo
37+
concurrency:
38+
# Shared concurrency group wih preview cleanup.
39+
group: "preview-${{ github.event.number }}"
40+
cancel-in-progress: true
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
45+
46+
- name: Setup Hugo
47+
uses: peaceiris/actions-hugo@v3
48+
with:
49+
hugo-version: "latest"
50+
extended: true
51+
52+
- name: Setup Node
53+
uses: actions/setup-node@v4
54+
with:
55+
node-version: "22"
56+
57+
- name: Cache dependencies
58+
uses: actions/cache@v4
59+
with:
60+
path: ~/.npm
61+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
62+
restore-keys: |
63+
${{ runner.os }}-node-
64+
65+
- run: npm ci
66+
- run: hugo --minify
67+
env:
68+
# HUGO_BASEURL: https://${{ github.repository_owner }}.github.io/${{ github.repository }}/previews/PR-${{ github.event.number }}/
69+
# While private, GitHub uses an obfuscated url instead:
70+
HUGO_BASEURL: https://vigilant-guacamole-plnwrm9.pages.github.io/previews/PR-${{ github.event.number }}/
71+
HUGO_ENVIRONMENT: preview
72+
HUGO_RELATIVEURLS: false
73+
74+
- name: Deploy
75+
# If run from a fork, GitHub write operations will fail.
76+
if: ${{ !github.event.pull_request.head.repo.fork }}
77+
uses: peaceiris/actions-gh-pages@v4
78+
with:
79+
github_token: ${{ secrets.GITHUB_TOKEN }}
80+
publish_dir: .hugo/public
81+
destination_dir: ./previews/PR-${{ github.event.number }}
82+
commit_message: "stage: PR-${{ github.event.number }}: ${{ github.event.head_commit.message }}"
83+
84+
- name: Comment
85+
# If run from a fork, GitHub write operations will fail.
86+
if: ${{ !github.event.pull_request.head.repo.fork }}
87+
uses: actions/github-script@v7
88+
with:
89+
script: |
90+
github.rest.issues.createComment({
91+
issue_number: context.payload.number,
92+
owner: context.repo.owner,
93+
repo: context.repo.repo,
94+
body: "🔎 Preview at https://vigilant-guacamole-plnwrm9.pages.github.io/previews/PR-${{ github.event.number }}/"
95+
})

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1+
# direnv
2+
.envrc
3+
14
# vscode
25
.vscode/
6+
7+
# npm
8+
node_modules
9+
10+
# hugo
11+
.hugo/public/
12+
.hugo/resources/_gen
13+
.hugo_build.lock

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "docs2/themes/godocs"]
2+
path = docs2/themes/godocs
3+
url = https://github.com/themefisher/godocs.git

.hugo/archetypes/default.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
+++
2+
date = '{{ .Date }}'
3+
draft = true
4+
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
5+
+++

.hugo/assets/icons/logo.svg

+1
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$primary: #D84040;
2+
$secondary: #8E1616;

.hugo/go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/googleapis/genai-toolbox
2+
3+
go 1.23.2
4+
5+
require github.com/google/docsy v0.11.0 // indirect

.hugo/go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
github.com/FortAwesome/Font-Awesome v0.0.0-20240716171331-37eff7fa00de/go.mod h1:IUgezN/MFpCDIlFezw3L8j83oeiIuYoj28Miwr/KUYo=
2+
github.com/google/docsy v0.11.0 h1:QnV40cc28QwS++kP9qINtrIv4hlASruhC/K3FqkHAmM=
3+
github.com/google/docsy v0.11.0/go.mod h1:hGGW0OjNuG5ZbH5JRtALY3yvN8ybbEP/v2iaK4bwOUI=
4+
github.com/twbs/bootstrap v5.3.3+incompatible/go.mod h1:fZTSrkpSf0/HkL0IIJzvVspTt1r9zuf7XlZau8kpcY0=

0 commit comments

Comments
 (0)