1515 schedule :
1616 - cron : ' 0 2 * * *' # 02:00 UTC daily
1717 workflow_dispatch :
18+ inputs :
19+ branch :
20+ description : " Build & deploy a single branch (e.g. master or stable34). Leave empty to build master + all supported stable branches."
21+ required : false
22+ type : string
23+ default : " "
1824
1925permissions :
2026 contents : read
@@ -30,15 +36,46 @@ jobs:
3036 outputs :
3137 branches : ${{ steps.set.outputs.branches }}
3238 steps :
33- - name : Collect master and stable branches
39+ - name : Checkout repository
40+ uses : actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
41+
42+ - name : Setup PHP
43+ uses : shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2.37.2
44+ with :
45+ php-version : ' 8.3'
46+
47+ - name : Compute branch matrix
3448 id : set
3549 env :
36- GH_TOKEN : ${{ github.token }}
50+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
51+ INPUT_BRANCH : ${{ inputs.branch }}
3752 run : |
38- stable_branches=$(gh api "repos/${{ github.repository }}/branches" --paginate \
39- --jq '.[].name | select(startswith("stable"))' | sort -Vr)
40- # Build a JSON array: ["master", "stable34", "stable33", ...]
41- branches_json=$(printf '%s\n' master ${stable_branches} | jq -R . | jq -cs .)
53+ # Manual single-branch dispatch: build only the requested branch.
54+ if [ -n "${INPUT_BRANCH}" ]; then
55+ branches_json=$(printf '%s' "${INPUT_BRANCH}" | jq -R . | jq -cs .)
56+ echo "Single-branch dispatch: ${branches_json}"
57+ echo "branches=${branches_json}" >> $GITHUB_OUTPUT
58+ exit 0
59+ fi
60+
61+ # Scheduled / plain dispatch: master + every stable branch that is still
62+ # within the support window. Ancient branches (e.g. stable10) are on the
63+ # remote but out of support and would blow past the 256-jobs-per-run cap.
64+ nums=$(git ls-remote --heads origin "heads/stable[0-9][0-9]" \
65+ | sed -n 's?.*refs/heads/stable\([0-9]\{2\}\)$?\1?p' | sort -n)
66+
67+ # Reuse the shared helper to get the supported range (lowest..highest).
68+ eval $(php build/detect-versions.php ${nums})
69+ echo "Supported stable range: ${lowest_stable}..${highest_stable}"
70+
71+ selected="master"
72+ for n in ${nums}; do
73+ if [ "$n" -ge "$lowest_stable" ] && [ "$n" -le "$highest_stable" ]; then
74+ selected="${selected} stable${n}"
75+ fi
76+ done
77+
78+ branches_json=$(printf '%s\n' ${selected} | jq -R . | jq -cs .)
4279 echo "Matrix branches: ${branches_json}"
4380 echo "branches=${branches_json}" >> $GITHUB_OUTPUT
4481
@@ -109,10 +146,12 @@ jobs:
109146 id : apply
110147 if : steps.staged.outputs.has_stage == 'true'
111148 run : |
149+ deployed=""
112150 for d in stage/*/; do
113151 [ -d "$d" ] || continue
114152 branch="$(basename "$d")"
115153 echo "Applying version folder: ${branch}"
154+ deployed="${deployed} ${branch}"
116155
117156 mkdir -p "server/${branch}"
118157 for artifact in "stage/${branch}"/*; do
@@ -132,6 +171,10 @@ jobs:
132171 done
133172 done
134173
174+ # Record which folders we deployed this run, so later steps only touch
175+ # those (not the ancient version folders already present on gh-pages).
176+ echo "folders=$(echo ${deployed} | xargs)" >> $GITHUB_OUTPUT
177+
135178 # Cleanup empty directories
136179 find . -type d -empty -delete
137180
@@ -182,17 +225,50 @@ jobs:
182225 if : steps.apply.outputs.has_changes == 'true'
183226 run : |
184227 default_branch="${{ github.event.repository.default_branch }}"
185- git fetch origin "${default_branch}"
228+ # gh-pages is checked out single-branch, so there is no origin/<default>
229+ # tracking ref. Fetch with an explicit refspec to create it.
230+ git fetch origin "${default_branch}:refs/remotes/origin/${default_branch}"
186231 git checkout "origin/${default_branch}" -- go.php/index.html user_manual/index.html
187232
188- for d in server/*/; do
189- [ -d "$d" ] || continue
190- branch="$(basename "$d")"
233+ # Only the folders deployed this run — not every historical version
234+ # already on gh-pages (some old ones have an incompatible layout).
235+ for branch in ${{ steps.apply.outputs.folders }}; do
236+ rm -rf "server/${branch}/go.php"
191237 mkdir -p "server/${branch}/go.php" "server/${branch}/user_manual"
192238 cp go.php/index.html "server/${branch}/go.php/index.html"
193239 cp user_manual/index.html "server/${branch}/user_manual/index.html"
194240 done
195241
242+ # ========================================================================
243+ # COMPOSE PR BODY — per-version change counts
244+ # ========================================================================
245+ - name : Compose PR body
246+ id : body
247+ if : steps.apply.outputs.has_changes == 'true'
248+ run : |
249+ # Stage everything so new files count too (create-pull-request commits this).
250+ git add -A
251+ {
252+ echo "text<<PR_BODY_EOF"
253+ echo "This PR was automatically generated by the scheduled deploy workflow."
254+ echo ""
255+ echo "Documentation rebuilt for: **${{ steps.apply.outputs.folders }}**"
256+ echo ""
257+ echo "| Version folder | Files changed |"
258+ echo "| --- | ---: |"
259+ total=0
260+ for branch in ${{ steps.apply.outputs.folders }}; do
261+ n=$(git diff --cached --name-only -- "server/${branch}" | wc -l | tr -d ' ')
262+ total=$((total + n))
263+ echo "| \`${branch}\` | ${n} |"
264+ done
265+ # Files outside the deployed version folders (redirects, robots.txt, …).
266+ other=$(git diff --cached --name-only -- . ':(exclude)server/*' | wc -l | tr -d ' ')
267+ echo "| _other_ | ${other} |"
268+ echo "| **Total** | **$((total + other))** |"
269+ echo "PR_BODY_EOF"
270+ } >> "$GITHUB_OUTPUT"
271+
196272 - name : Create Pull Request for documentation deployment
197273 uses : peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
198274 id : cpr
@@ -206,9 +282,7 @@ jobs:
206282 branch : " automated/deploy/documentation"
207283 base : gh-pages
208284 title : " Documentation update"
209- body : |
210- This PR was automatically generated by the scheduled deploy workflow
211- and includes the latest documentation for all built versions.
285+ body : ${{ steps.body.outputs.text }}
212286 delete-branch : true
213287 labels : " automated, 3. to review"
214288
0 commit comments