Skip to content

Commit a9244d7

Browse files
committed
ci: restrict scheduled deploy matrix to supported branches
The consolidated deploy matrix iterated every stable* branch on the remote, including long out-of-support ones (stable9..stable29). In a single run this also blows past the 256-jobs-per-run limit and wastes CI on branches that no longer build. - prepare now builds master + only the stable branches within the support window, reusing build/detect-versions.php for the lowest..highest range. - workflow_dispatch gains an optional "branch" input to build & deploy a single branch on demand (empty = master + all supported stables). Assisted-by: ClaudeCode:claude-opus-4-8 Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent 981c443 commit a9244d7

1 file changed

Lines changed: 46 additions & 7 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ on:
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

1925
permissions:
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
@@ -182,7 +219,9 @@ jobs:
182219
if: steps.apply.outputs.has_changes == 'true'
183220
run: |
184221
default_branch="${{ github.event.repository.default_branch }}"
185-
git fetch origin "${default_branch}"
222+
# gh-pages is checked out single-branch, so there is no origin/<default>
223+
# tracking ref. Fetch with an explicit refspec to create it.
224+
git fetch origin "${default_branch}:refs/remotes/origin/${default_branch}"
186225
git checkout "origin/${default_branch}" -- go.php/index.html user_manual/index.html
187226
188227
for d in server/*/; do

0 commit comments

Comments
 (0)