Skip to content

Commit e9302f7

Browse files
committed
Support building multiple branches when scheduling trigger runs
1 parent de61ae5 commit e9302f7

File tree

1 file changed

+58
-15
lines changed

1 file changed

+58
-15
lines changed

.github/workflows/deploy.yml

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,81 @@ jobs:
2626
setup:
2727
runs-on: ubuntu-latest
2828
outputs:
29-
java-versions: ${{ steps.set-matrix.outputs.versions }}
29+
matrix: ${{ steps.set-matrix.outputs.matrix }}
3030
steps:
31-
- name: Determine JDK versions based on branch
31+
- name: Determine branches and JDK versions
3232
id: set-matrix
3333
run: |
34-
BRANCH="${{ env.BRANCH }}"
35-
# Define JDK versions for each branch
36-
# Main branch supports all versions
37-
if [[ "$BRANCH" == "main" ]] || [[ "$BRANCH" == "4.3.x" ]]; then
38-
echo 'versions=["17","21","25"]' >> $GITHUB_OUTPUT
39-
elif [[ "$BRANCH" == "4.2.x" ]] || [[ "$BRANCH" == "4.1.x" ]]; then
40-
echo 'versions=["17","21"]' >> $GITHUB_OUTPUT
41-
elif [[ "$BRANCH" == "3.1.x" ]]; then
42-
echo 'versions=["8","11","17"]' >> $GITHUB_OUTPUT
43-
# Default: use all versions if branch not specified
34+
echo "=== Workflow Debug Information ==="
35+
echo "Event name: ${{ github.event_name }}"
36+
echo "Ref name: ${{ github.ref_name }}"
37+
echo "Branch from env: ${{ env.BRANCH }}"
38+
echo ""
39+
40+
# Function to get JDK versions for a branch (returns space-separated list)
41+
get_jdk_versions() {
42+
local branch=$1
43+
if [[ "$branch" == "main" ]] || [[ "$branch" == "4.3.x" ]]; then
44+
echo "17 21 25"
45+
elif [[ "$branch" == "4.2.x" ]] || [[ "$branch" == "4.1.x" ]]; then
46+
echo "17 21"
47+
elif [[ "$branch" == "3.1.x" ]]; then
48+
echo "8 11 17"
49+
else
50+
echo "17 21 25"
51+
fi
52+
}
53+
54+
# Determine which branches to build
55+
if [[ "${{ github.event_name }}" == "schedule" ]]; then
56+
BRANCHES=("main" "4.3.x")
57+
echo "Trigger: Scheduled run - building multiple branches"
4458
else
45-
echo 'versions=["17","21","25"]' >> $GITHUB_OUTPUT
59+
BRANCHES=("${{ env.BRANCH }}")
60+
echo "Trigger: ${{ github.event_name }} - building single branch"
4661
fi
62+
63+
echo ""
64+
echo "=== Branches to Build ==="
65+
for BRANCH in "${BRANCHES[@]}"; do
66+
echo " - $BRANCH"
67+
done
68+
69+
echo ""
70+
echo "=== Java Versions per Branch ==="
71+
# Build matrix by iterating over branches and their JDK versions
72+
MATRIX_ENTRIES=()
73+
for BRANCH in "${BRANCHES[@]}"; do
74+
JDK_VERSIONS=$(get_jdk_versions "$BRANCH")
75+
echo " $BRANCH: $JDK_VERSIONS"
76+
for VERSION in $JDK_VERSIONS; do
77+
MATRIX_ENTRIES+=("{\"branch\":\"$BRANCH\",\"java-version\":\"$VERSION\"}")
78+
done
79+
done
80+
81+
# Join entries with comma and wrap in array
82+
MATRIX_JSON="[$(IFS=,; echo "${MATRIX_ENTRIES[*]}")]"
83+
84+
echo ""
85+
echo "=== Generated Matrix ==="
86+
echo "$MATRIX_JSON" | python3 -m json.tool || echo "$MATRIX_JSON"
87+
echo ""
88+
89+
echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
4790
4891
build:
4992
needs: setup
5093
runs-on: ubuntu-latest
5194
timeout-minutes: 60
5295
strategy:
5396
matrix:
54-
java-version: ${{ fromJson(needs.setup.outputs.java-versions) }}
97+
include: ${{ fromJson(needs.setup.outputs.matrix) }}
5598

5699
steps:
57100
- name: Checkout code
58101
uses: actions/checkout@v5
59102
with:
60-
ref: ${{ env.BRANCH }}
103+
ref: ${{ matrix.branch }}
61104
clean: true # Equivalent to WipeWorkspace extension
62105

63106
- name: Set up JDK ${{ matrix.java-version }}

0 commit comments

Comments
 (0)