Skip to content

Commit 5f0ea88

Browse files
committed
remove prs from pull_request_target and add second hugo config
1 parent a8c6016 commit 5f0ea88

File tree

6 files changed

+218
-96
lines changed

6 files changed

+218
-96
lines changed

.github/workflows/deploy_dev_docs_to_cf.yaml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2025 Google LLC
1+
# Copyright 2026 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -23,7 +23,8 @@ on:
2323
- main
2424
paths:
2525
- 'docs/**'
26-
- 'github/workflows/docs**'
26+
- '.github/workflows/docs*_cf.yaml'
27+
- '.github/workflows/deploy*_cf.yaml'
2728
- '.hugo/**'
2829

2930
# Allow triggering manually.
@@ -45,19 +46,6 @@ jobs:
4546
fetch-depth: 0
4647
submodules: recursive
4748

48-
- name: Patch Config and Templates for Cloudflare
49-
run: |
50-
# Strip GitHub domain from config
51-
sed -i 's|https://googleapis.github.io/genai-toolbox/|/|g' hugo.toml
52-
# Strip prefix from navbar partial
53-
if [ -f "layouts/partials/navbar-version-selector.html" ]; then
54-
sed -i 's|/genai-toolbox/|/|g' layouts/partials/navbar-version-selector.html
55-
fi
56-
# Disable the migration banner for the new live site
57-
if [ -f "static/js/migration-banner.js" ]; then
58-
echo "" > static/js/migration-banner.js
59-
fi
60-
6149
- name: Setup Hugo
6250
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
6351
with:
@@ -78,7 +66,7 @@ jobs:
7866
${{ runner.os }}-node-
7967
8068
- run: npm ci
81-
- run: hugo --minify
69+
- run: hugo --minify --config hugo.cloudflare.toml
8270
env:
8371
HUGO_BASEURL: https://mcp-toolbox.dev/dev/
8472
HUGO_RELATIVEURLS: false

.github/workflows/deploy_previous_version_docs_to_cf.yaml

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Copyright 2025 Google LLC
1+
# Copyright 2026 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
55
# You may obtain a copy of the License at
66
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
7+
# http://www.apache.org/licenses/LICENSE-2.0
88
#
99
# Unless required by applicable law or agreed to in writing, software
1010
# distributed under the License is distributed on an "AS IS" BASIS,
@@ -52,21 +52,6 @@ jobs:
5252
# Move the old content directory into place
5353
mv ./old_version_source/docs docs
5454
55-
- name: Patch Config and Templates for Cloudflare
56-
run: |
57-
# Strip the GitHub domain from the Hugo config
58-
sed -i 's|https://googleapis.github.io/genai-toolbox/|/|g' .hugo/hugo.toml
59-
60-
# Strip the hardcoded path prefix from the navbar selector
61-
if [ -f ".hugo/layouts/partials/navbar-version-selector.html" ]; then
62-
sed -i 's|/genai-toolbox/|/|g' .hugo/layouts/partials/navbar-version-selector.html
63-
fi
64-
65-
# Disable the migration banner for the new live site
66-
if [ -f ".hugo/static/js/migration-banner.js" ]; then
67-
echo "" > .hugo/static/js/migration-banner.js
68-
fi
69-
7055
- name: Setup Hugo and Node
7156
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
7257
with:
@@ -81,7 +66,7 @@ jobs:
8166
working-directory: .hugo
8267

8368
- name: Build Hugo Site for Archived Version
84-
run: hugo --minify
69+
run: hugo --minify --config hugo.cloudflare.toml
8570
working-directory: .hugo
8671
env:
8772
HUGO_BASEURL: https://mcp-toolbox.dev/${{ github.event.inputs.version_tag }}/
@@ -102,7 +87,7 @@ jobs:
10287
run: rm -rf .hugo/public
10388

10489
- name: Build Hugo Site
105-
run: hugo --minify
90+
run: hugo --minify --config hugo.cloudflare.toml
10691
working-directory: .hugo
10792
env:
10893
HUGO_BASEURL: https://mcp-toolbox.dev/
@@ -116,4 +101,4 @@ jobs:
116101
publish_branch: cloudflare-pages
117102
keep_files: true
118103
allow_empty_commit: true
119-
commit_message: "deploy: docs to root for ${{ github.event.inputs.version_tag }}"
104+
commit_message: "deploy: docs to root for ${{ github.event.inputs.version_tag }}"

.github/workflows/deploy_versioned_docs_to_cf.yaml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2025 Google LLC
1+
# Copyright 2026 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -40,21 +40,6 @@ jobs:
4040
RELEASE_TAG: ${{ github.event.release.tag_name }}
4141
run: echo "VERSION=${RELEASE_TAG}" >> "$GITHUB_OUTPUT"
4242

43-
- name: Patch Config and Templates for Cloudflare
44-
run: |
45-
# Strip the GitHub domain from the Hugo config
46-
sed -i 's|https://googleapis.github.io/genai-toolbox/|/|g' .hugo/hugo.toml
47-
48-
# Strip the hardcoded path prefix from the navbar selector
49-
if [ -f ".hugo/layouts/partials/navbar-version-selector.html" ]; then
50-
sed -i 's|/genai-toolbox/|/|g' .hugo/layouts/partials/navbar-version-selector.html
51-
fi
52-
53-
# Disable the migration banner for the new live site
54-
if [ -f ".hugo/static/js/migration-banner.js" ]; then
55-
echo "" > .hugo/static/js/migration-banner.js
56-
fi
57-
5843
- name: Setup Hugo
5944
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
6045
with:
@@ -71,7 +56,7 @@ jobs:
7156
working-directory: .hugo
7257

7358
- name: Build Hugo Site
74-
run: hugo --minify
59+
run: hugo --minify --config hugo.cloudflare.toml
7560
working-directory: .hugo
7661
env:
7762
HUGO_BASEURL: https://mcp-toolbox.dev/${{ steps.get_version.outputs.VERSION }}/
@@ -91,7 +76,7 @@ jobs:
9176
run: rm -rf .hugo/public
9277

9378
- name: Build Hugo Site
94-
run: hugo --minify
79+
run: hugo --minify --config hugo.cloudflare.toml
9580
working-directory: .hugo
9681
env:
9782
HUGO_BASEURL: https://mcp-toolbox.dev/

.github/workflows/docs_preview_clean_cf.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@ on:
2323
pull_request:
2424
types:
2525
- closed
26-
pull_request_target:
27-
types:
28-
- closed
2926

3027
jobs:
3128
clean:
32-
if: "${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name || contains(github.event.pull_request.labels.*.name, 'docs: deploy-preview') }}"
29+
# Only run for PRs from the same repository to ensure secret access
30+
if: "${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}"
3331
runs-on: ubuntu-24.04
3432
concurrency:
3533
# Shared concurrency group with preview staging.
Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2025 Google LLC
1+
# Copyright 2026 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -22,24 +22,16 @@ permissions:
2222
# not compatible with branch or manual triggers.
2323
on:
2424
pull_request:
25-
# Sync with github_actions_preview_fallback.yml on.pull_request.paths-ignore
2625
paths:
2726
- 'docs/**'
28-
- 'github/workflows/docs**'
29-
- '.hugo/**'
30-
pull_request_target:
31-
types: [labeled]
32-
paths:
33-
- 'docs/**'
34-
- 'github/workflows/docs**'
27+
- '.github/workflows/docs*_cf.yaml'
28+
- '.github/workflows/deploy*_cf.yaml'
3529
- '.hugo/**'
3630

3731
jobs:
3832
preview:
39-
# run job on proper workflow event triggers (skip job for pull_request event
40-
# from forks and only run pull_request_target for "docs: deploy-preview"
41-
# label)
42-
if: "${{ (github.event.action != 'labeled' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) || github.event.label.name == 'docs: deploy-preview' }}"
33+
# Only run for PRs from the same repository to ensure secret access
34+
if: "${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}"
4335
runs-on: ubuntu-24.04
4436
defaults:
4537
run:
@@ -51,23 +43,9 @@ jobs:
5143
steps:
5244
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
5345
with:
54-
# Check out the fork repository explicitly if it's a fork PR
5546
ref: ${{ github.event.pull_request.head.sha }}
5647
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod
5748

58-
- name: Patch Config and Templates for Cloudflare
59-
run: |
60-
# Strip GitHub domain from config
61-
sed -i 's|https://googleapis.github.io/genai-toolbox/|/|g' hugo.toml
62-
# Strip prefix from navbar partial
63-
if [ -f "layouts/partials/navbar-version-selector.html" ]; then
64-
sed -i 's|/genai-toolbox/|/|g' layouts/partials/navbar-version-selector.html
65-
fi
66-
# Disable the migration banner for the CF preview site
67-
if [ -f "static/js/migration-banner.js" ]; then
68-
echo "" > static/js/migration-banner.js
69-
fi
70-
7149
- name: Setup Hugo
7250
uses: peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
7351
with:
@@ -88,11 +66,11 @@ jobs:
8866
${{ runner.os }}-node-
8967
9068
- run: npm ci
91-
- run: hugo --minify
69+
- run: hugo --minify --config hugo.cloudflare.toml
9270
env:
9371
HUGO_BASEURL: "/"
9472
HUGO_ENVIRONMENT: preview
95-
HUGO_RELATIVEURLS: true
73+
HUGO_RELATIVEURLS: false
9674

9775
- name: Deploy to Cloudflare Pages via Wrangler
9876
id: cf_deploy
@@ -102,13 +80,13 @@ jobs:
10280
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
10381
command: pages deploy .hugo/public --project-name toolbox-docs --branch pr-${{ github.event.number }}
10482

105-
- name: Comment PR Link
106-
uses: marocchino/sticky-pull-request-comment@v2
83+
- name: Comment
84+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
10785
with:
108-
header: cf-preview-link
109-
message: |
110-
🚀 **Cloudflare Preview is ready!**
111-
112-
🔎 View Preview: ${{ steps.cf_deploy.outputs.pages-deployment-alias-url }}
113-
114-
*(Note: This comment will automatically update when new commits are pushed).*
86+
script: |
87+
github.rest.issues.createComment({
88+
issue_number: context.payload.number,
89+
owner: context.repo.owner,
90+
repo: context.repo.repo,
91+
body: "🚀 **Cloudflare Preview is building!**\n\n🔎 View Preview: ${{ steps.cf_deploy.outputs.pages-deployment-alias-url }}\n\n*(Note: It may take a minute or two for Cloudflare to finish deploying the branch)*"
92+
})

0 commit comments

Comments
 (0)