-
Notifications
You must be signed in to change notification settings - Fork 0
241 lines (216 loc) · 8.83 KB
/
_reusable-build-deploy.yml
File metadata and controls
241 lines (216 loc) · 8.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# Reusable workflow: build Hugo site (optionally with product docs) and deploy.
# Called by publish-site.yml and publish-assets.yml.
name: _reusable-build-deploy
on:
workflow_call:
inputs:
base_url:
description: 'Base URL override (empty = use config default)'
type: string
default: ''
all_products:
type: boolean
default: false
annotation:
type: boolean
default: false
assembly:
type: boolean
default: false
classification:
type: boolean
default: false
comparison:
type: boolean
default: false
conversion:
type: boolean
default: false
editor:
type: boolean
default: false
markdown:
type: boolean
default: false
merger:
type: boolean
default: false
metadata:
type: boolean
default: false
parser:
type: boolean
default: false
redaction:
type: boolean
default: false
search:
type: boolean
default: false
signature:
type: boolean
default: false
total:
type: boolean
default: false
viewer:
type: boolean
default: false
watermark:
type: boolean
default: false
secrets:
DOCS_SSH_HOST:
required: true
DEPLOY_SSH_DIR:
required: true
DOCS_SSH_USER:
required: true
DOCS_SSH_KEY:
required: true
jobs:
build:
runs-on: self-hosted
steps:
- uses: actions/checkout@v4
- name: Install Hugo
run: |
curl -LO https://github.com/gohugoio/hugo/releases/download/v0.101.0/hugo_extended_0.101.0_Linux-64bit.deb
sudo dpkg -i hugo_extended_0.101.0_Linux-64bit.deb
- name: Download product documentation
if: >-
${{
inputs.all_products ||
inputs.annotation || inputs.assembly || inputs.classification ||
inputs.comparison || inputs.conversion || inputs.editor ||
inputs.markdown || inputs.merger || inputs.metadata ||
inputs.parser || inputs.redaction || inputs.search ||
inputs.signature || inputs.total || inputs.viewer || inputs.watermark
}}
run: |
# Full product registry: "key:Name"
ALL_PRODUCTS="
annotation:Annotation
assembly:Assembly
classification:Classification
comparison:Comparison
conversion:Conversion
editor:Editor
markdown:Markdown
merger:Merger
metadata:Metadata
parser:Parser
redaction:Redaction
search:Search
signature:Signature
total:Total
viewer:Viewer
watermark:Watermark
"
# Build the list of products to download
if [[ "${{ inputs.all_products }}" == "true" ]]; then
PRODUCTS="$ALL_PRODUCTS"
echo "Mode: all products"
else
PRODUCTS=""
for entry in $ALL_PRODUCTS; do
key="${entry%%:*}"
case "$key" in
annotation) [[ "${{ inputs.annotation }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
assembly) [[ "${{ inputs.assembly }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
classification) [[ "${{ inputs.classification }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
comparison) [[ "${{ inputs.comparison }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
conversion) [[ "${{ inputs.conversion }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
editor) [[ "${{ inputs.editor }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
markdown) [[ "${{ inputs.markdown }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
merger) [[ "${{ inputs.merger }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
metadata) [[ "${{ inputs.metadata }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
parser) [[ "${{ inputs.parser }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
redaction) [[ "${{ inputs.redaction }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
search) [[ "${{ inputs.search }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
signature) [[ "${{ inputs.signature }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
total) [[ "${{ inputs.total }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
viewer) [[ "${{ inputs.viewer }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
watermark) [[ "${{ inputs.watermark }}" == "true" ]] && PRODUCTS="$PRODUCTS $entry" ;;
esac
done
echo "Mode: selected products"
fi
echo "Products to download: $PRODUCTS"
for entry in $PRODUCTS; do
product="${entry%%:*}"
product_name="${entry##*:}"
repo_url="https://github.com/groupdocs-${product}/GroupDocs.${product_name}-Docs.git"
echo "::group::Downloading ${product} documentation"
echo "Repository: groupdocs-${product}/GroupDocs.${product_name}-Docs"
git clone --depth 1 "${repo_url}" "temp-${product}" 2>&1 || {
echo "::warning::Failed to clone GroupDocs.${product_name}-Docs"
echo "::endgroup::"
continue
}
# Create content directory for this product
mkdir -p "content/${product}"
# Copy product family index page
if [ -f "temp-${product}/_index.md" ]; then
cp "temp-${product}/_index.md" "content/${product}/"
echo "Copied _index.md"
fi
# Copy platform-specific documentation folders
for platform in net java nodejs-java python-net; do
if [ -d "temp-${product}/${platform}" ]; then
cp -r "temp-${product}/${platform}" "content/${product}/"
echo "Copied ${platform}/ folder"
fi
done
# Cleanup cloned repo
rm -rf "temp-${product}"
echo "::endgroup::"
done
echo ""
echo "=== Content structure ==="
ls -la content/
- name: Build site
run: |
HUGO_ARGS="--minify"
if [ -n "${{ inputs.base_url }}" ]; then
HUGO_ARGS="$HUGO_ARGS --baseURL '${{ inputs.base_url }}'"
fi
eval hugo $HUGO_ARGS
- name: Move MD files to ugly URLs
run: ./move_md_to_ugly_urls.sh
- name: Remove index.json (published separately by publish-assets workflow)
if: ${{ !inputs.all_products }}
run: rm -f ./public/index.json
- name: Remove llms.txt and llms-full.txt (incomplete on partial builds)
if: ${{ !inputs.all_products }}
run: rm -f ./public/llms.txt ./public/llms-full.txt
- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DOCS_SSH_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh-keyscan -H ${{ secrets.DOCS_SSH_HOST }} >> ~/.ssh/known_hosts 2>/dev/null
- name: Deploy artifacts
run: |
SSH_OPTS="-i ~/.ssh/deploy_key -o ServerAliveInterval=60 -o ServerAliveCountMax=30"
RSYNC_OPTS="-vr --inplace --checksum --chmod=D755,F644 --timeout=300"
REMOTE="${{ secrets.DOCS_SSH_USER }}@${{ secrets.DOCS_SSH_HOST }}:${{ secrets.DEPLOY_SSH_DIR }}"
if [[ "${{ inputs.all_products }}" == "true" ]]; then
# Full build: sync everything, remove stale files
# Exclude sitemaps/ — per-product sitemaps are deployed by product repos
rsync $RSYNC_OPTS --delete --exclude='sitemaps/' -e "ssh $SSH_OPTS" public/ "$REMOTE"
else
# Partial build: update root-level files without deleting anything
rsync $RSYNC_OPTS -e "ssh $SSH_OPTS" public/ "$REMOTE"
# Then clean up stale files within each built product directory
KNOWN_PRODUCTS="annotation assembly classification comparison conversion editor markdown merger metadata parser redaction search signature total viewer watermark"
for product in $KNOWN_PRODUCTS; do
if [ -d "public/$product" ]; then
echo "Cleaning up stale files in $product/"
rsync $RSYNC_OPTS --delete -e "ssh $SSH_OPTS" "public/$product/" "$REMOTE/$product/"
fi
done
fi
- name: Cleanup SSH key
if: always()
run: rm -f ~/.ssh/deploy_key