Skip to content

Commit f12c4bf

Browse files
dishaprakashgemini-code-assist[bot]averikitsch
authored
chore: Add workflows to deploy to cloudflare (#2652)
## Description This PR adds workflows necessary for the cloudflare pages deployment Changes: - Compressed `edit-headers.gif` from 38MiB to 8MiB for smoother cloudflare deployment - `deploy_dev_docs_to_cf.yaml`: To build and push the hugo site to branch `cloudflare-pages` - `deploy_previous_version_docs_to_cf.yaml`: To build and push older versions to branch `cloudflare-pages` at `v<version>/` and `/` (root) - `deploy_versioned_docs_to_cf.yaml`: To build and push newly released version to branch `cloudflare-pages` at `v<version>/` and `/` (root) - `cloudflare_sync.yaml`: To one shot deploy the `cloudflare-pages` branch to `mcp-toolbox.dev` through the cloudflare wrangler GHA - `docs_preview_deploy_cf.yaml`: To build and deploy PR Preview (without pull_request_target) to cloudflare and attach a comment on the PR with the deployed link. Uses `marocchino/sticky-pull-request-comment@v2` action to mkae sure the preview comment is updated instead of creating a new comment on every deployment. - `docs_preview_clean_cf.yaml`: To clean PR Preview (without pull_request_target) from cloudflare and attach a comment on the PR The CF deployement for pr previews will fail until we add the tokens into repo secret. I will add those right before merging to main ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here> --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Averi Kitsch <akitsch@google.com>
1 parent 99bc05b commit f12c4bf

File tree

9 files changed

+644
-1
lines changed

9 files changed

+644
-1
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2026 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: "Sync v1 docsite to Cloudflare"
16+
17+
concurrency:
18+
group: cloudflare-sync
19+
cancel-in-progress: true
20+
21+
on:
22+
workflow_run:
23+
workflows: ["CF: Deploy Dev Docs", "CF: Deploy Versioned Docs", "CF: Deploy Previous Version Docs"]
24+
types: [completed]
25+
26+
jobs:
27+
deploy:
28+
runs-on: ubuntu-latest
29+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
ref: 'cloudflare-pages'
34+
- name: Cleanup
35+
run: |
36+
rm -rf .git
37+
- name: Cloudflare Deploy
38+
uses: cloudflare/wrangler-action@v3
39+
with:
40+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
41+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
42+
command: pages deploy . --project-name=toolbox-docs --branch=main
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Copyright 2026 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: "CF: Deploy Dev Docs"
16+
17+
permissions:
18+
contents: write
19+
20+
on:
21+
push:
22+
branches:
23+
- main
24+
paths:
25+
- 'docs/**'
26+
- '.github/workflows/docs*_cf.yaml'
27+
- '.github/workflows/deploy*_cf.yaml'
28+
- '.hugo/**'
29+
30+
# Allow triggering manually.
31+
workflow_dispatch:
32+
33+
jobs:
34+
deploy:
35+
runs-on: ubuntu-24.04
36+
defaults:
37+
run:
38+
working-directory: .hugo
39+
# This shared concurrency group ensures only one docs deployment runs at a time.
40+
concurrency:
41+
group: cf-docs-update
42+
cancel-in-progress: false
43+
steps:
44+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
45+
with:
46+
fetch-depth: 0
47+
submodules: recursive
48+
49+
- name: Setup Hugo
50+
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
51+
with:
52+
hugo-version: "0.145.0"
53+
extended: true
54+
55+
- name: Setup Node
56+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
57+
with:
58+
node-version: "22"
59+
60+
- name: Cache dependencies
61+
uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5
62+
with:
63+
path: ~/.npm
64+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
65+
restore-keys: |
66+
${{ runner.os }}-node-
67+
68+
- run: npm ci
69+
- run: hugo --minify --config hugo.cloudflare.toml
70+
env:
71+
HUGO_BASEURL: https://mcp-toolbox.dev/dev/
72+
HUGO_RELATIVEURLS: false
73+
74+
- name: Create Staging Directory
75+
run: |
76+
mkdir staging
77+
mv public staging/dev
78+
mv staging/dev/releases.releases staging/releases.releases
79+
80+
- name: Push to Cloudflare Branch
81+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
82+
with:
83+
github_token: ${{ secrets.GITHUB_TOKEN }}
84+
publish_dir: ./.hugo/staging
85+
publish_branch: cloudflare-pages
86+
keep_files: true
87+
commit_message: "deploy: ${{ github.event.head_commit.message }}"
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Copyright 2026 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: "CF: Deploy Previous Version Docs"
16+
17+
on:
18+
workflow_dispatch:
19+
inputs:
20+
version_tag:
21+
description: 'The old version tag to build docs for (e.g., v0.15.0)'
22+
required: true
23+
type: string
24+
25+
jobs:
26+
build_and_deploy:
27+
runs-on: ubuntu-latest
28+
permissions:
29+
contents: write
30+
31+
steps:
32+
- name: Checkout main branch (for latest templates and theme)
33+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
34+
with:
35+
ref: 'main'
36+
submodules: 'recursive'
37+
fetch-depth: 0
38+
39+
- name: Checkout old content from tag into a temporary directory
40+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
41+
with:
42+
ref: ${{ github.event.inputs.version_tag }}
43+
path: 'old_version_source' # Checkout into a temp subdir
44+
# Sparse checkout to only get the content directory
45+
sparse-checkout: |
46+
docs
47+
48+
- name: Replace content with old version
49+
run: |
50+
# Remove the current content directory from the main branch checkout
51+
rm -rf docs/
52+
# Move the old content directory into place
53+
mv ./old_version_source/docs docs
54+
55+
- name: Setup Hugo and Node
56+
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
57+
with:
58+
hugo-version: "0.145.0"
59+
extended: true
60+
- uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
61+
with:
62+
node-version: "22"
63+
64+
- name: Install Dependencies
65+
run: npm ci
66+
working-directory: .hugo
67+
68+
- name: Build Hugo Site for Archived Version
69+
run: hugo --minify --config hugo.cloudflare.toml
70+
working-directory: .hugo
71+
env:
72+
HUGO_BASEURL: https://mcp-toolbox.dev/${{ github.event.inputs.version_tag }}/
73+
HUGO_RELATIVEURLS: false
74+
75+
- name: Deploy to cloudflare-pages
76+
uses: peaceiris/actions-gh-pages@v4
77+
with:
78+
github_token: ${{ secrets.GITHUB_TOKEN }}
79+
publish_dir: .hugo/public
80+
publish_branch: cloudflare-pages
81+
destination_dir: ./${{ github.event.inputs.version_tag }}
82+
keep_files: true
83+
allow_empty_commit: true
84+
commit_message: "docs(backport): deploy docs for ${{ github.event.inputs.version_tag }}"
85+
86+
- name: Clean Build Directory
87+
run: rm -rf .hugo/public
88+
89+
- name: Build Hugo Site
90+
run: hugo --minify --config hugo.cloudflare.toml
91+
working-directory: .hugo
92+
env:
93+
HUGO_BASEURL: https://mcp-toolbox.dev/
94+
HUGO_RELATIVEURLS: false
95+
96+
- name: Deploy to root
97+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
98+
with:
99+
github_token: ${{ secrets.GITHUB_TOKEN }}
100+
publish_dir: .hugo/public
101+
publish_branch: cloudflare-pages
102+
keep_files: true
103+
allow_empty_commit: true
104+
commit_message: "deploy: docs to root for ${{ github.event.inputs.version_tag }}"
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Copyright 2026 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: "CF: Deploy Versioned Docs"
16+
17+
permissions:
18+
contents: write
19+
20+
on:
21+
release:
22+
types: [published]
23+
24+
jobs:
25+
deploy:
26+
runs-on: ubuntu-24.04
27+
# This shared concurrency group ensures only one docs deployment runs at a time.
28+
concurrency:
29+
group: cf-docs-update
30+
cancel-in-progress: false
31+
steps:
32+
- name: Checkout Code at Tag
33+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
34+
with:
35+
ref: ${{ github.event.release.tag_name }}
36+
37+
- name: Get Version from Release Tag
38+
id: get_version
39+
env:
40+
RELEASE_TAG: ${{ github.event.release.tag_name }}
41+
run: echo "VERSION=${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
42+
43+
- name: Setup Hugo
44+
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
45+
with:
46+
hugo-version: "0.145.0"
47+
extended: true
48+
49+
- name: Setup Node
50+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6
51+
with:
52+
node-version: "22"
53+
54+
- name: Install Dependencies
55+
run: npm ci
56+
working-directory: .hugo
57+
58+
- name: Build Hugo Site
59+
run: hugo --minify --config hugo.cloudflare.toml
60+
working-directory: .hugo
61+
env:
62+
HUGO_BASEURL: https://mcp-toolbox.dev/${{ steps.get_version.outputs.VERSION }}/
63+
HUGO_RELATIVEURLS: false
64+
65+
- name: Deploy
66+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
67+
with:
68+
github_token: ${{ secrets.GITHUB_TOKEN }}
69+
publish_dir: .hugo/public
70+
publish_branch: cloudflare-pages
71+
destination_dir: ./${{ steps.get_version.outputs.VERSION }}
72+
keep_files: true
73+
commit_message: "deploy: docs for ${{ steps.get_version.outputs.VERSION }}"
74+
75+
- name: Clean Build Directory
76+
run: rm -rf .hugo/public
77+
78+
- name: Build Hugo Site
79+
run: hugo --minify --config hugo.cloudflare.toml
80+
working-directory: .hugo
81+
env:
82+
HUGO_BASEURL: https://mcp-toolbox.dev/
83+
HUGO_RELATIVEURLS: false
84+
85+
- name: Deploy to root
86+
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
87+
with:
88+
github_token: ${{ secrets.GITHUB_TOKEN }}
89+
publish_dir: .hugo/public
90+
publish_branch: cloudflare-pages
91+
keep_files: true
92+
allow_empty_commit: true
93+
commit_message: "deploy: docs to root for ${{ steps.get_version.outputs.VERSION }}"

0 commit comments

Comments
 (0)