@@ -29,56 +29,36 @@ jobs:
2929 contents : write
3030
3131 steps :
32- - name : Checkout Tag (Code + Content )
32+ - name : Checkout main branch (for latest templates and theme )
3333 uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3434 with :
35- ref : ${{ github.event.inputs.version_tag }}
35+ ref : ' main '
3636 submodules : ' recursive'
3737 fetch-depth : 0
3838
39- - name : Apply Backports and Fixes
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'
44+ sparse-checkout : |
45+ docs
46+
47+ - name : Replace content with old version
4048 run : |
41- # 1. Fetch main to get the compressed GIF
42- git fetch origin main
43-
44- git show origin/main:docs/en/documentation/configuration/toolbox-ui/edit-headers.gif > docs/en/how-to/toolbox-ui/edit-headers.gif
45-
46- sed -i 's|/genai-toolbox/|/|g' .hugo/layouts/partials/navbar-version-selector.html
47-
48- sed -i 's|https://googleapis.github.io/genai-toolbox|https://mcp-toolbox.dev|g' .hugo/hugo.toml
49-
50- git show origin/main:.hugo/hugo.cloudflare.toml > modern_config.toml
51-
52- # Graft the future version list into the old config using Node.js!
53- node -e "
54- const fs = require('fs');
55- const modern = fs.readFileSync('modern_config.toml', 'utf8');
56- let old = fs.readFileSync('.hugo/hugo.toml', 'utf8');
57-
58- // Convert any old GitHub URLs to Cloudflare in the rest of the config
59- old = old.replace(/https:\/\/googleapis\.github\.io\/genai-toolbox/g, 'https://mcp-toolbox.dev');
60-
61- // Erase the outdated version list from the old config
62- old = old.replace(/\[\[params\.versions\]\][\s\S]*?(?=\n\[\[|\n\[|$)/g, '');
63-
64- // Extract the fully updated version list from the modern config
65- const modernVersions = modern.match(/\[\[params\.versions\]\][\s\S]*?(?=\n\[\[|\n\[|$)/g);
66-
67- // Inject the modern versions into the old config
68- if (modernVersions) {
69- fs.writeFileSync('.hugo/hugo.toml', old + '\n\n' + modernVersions.join('\n'));
70- } else {
71- fs.writeFileSync('.hugo/hugo.toml', old);
72- }
73- "
74-
75-
76- - name : Setup Hugo and Node
49+ # Remove the current content directory from the main branch checkout
50+ rm -rf docs/
51+ # Move the old content directory into place
52+ mv ./old_version_source/docs docs
53+
54+ - name : Setup Hugo
7755 uses : peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3
7856 with :
7957 hugo-version : " 0.161.1"
8058 extended : true
81- - uses : actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
59+
60+ - name : Setup Node
61+ uses : actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
8262 with :
8363 node-version : " 22"
8464
0 commit comments