Skip to content

Commit 9486fe3

Browse files
committed
Make Workflows run automatically from topic branch
Signed-off-by: Unnati Mishra <unnati.mishra@broadcom.com> Bump kind images workflow file Signed-off-by: Unnati Mishra <unnati.mishra@broadcom.com> Apply jq code Signed-off-by: Unnati Mishra <unnati.mishra@broadcom.com> Bump jq to run with -c Signed-off-by: Unnati Mishra <unnati.mishra@broadcom.com>
1 parent 028e7b7 commit 9486fe3

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

.github/workflows/nightly-build-kind-images.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
# 2:00 AM IST = 20:30 UTC (previous day)
66
- cron: '30 20 * * *'
77
workflow_dispatch:
8+
pull_request:
89

910
env:
1011
REGISTRY: ghcr.io
@@ -30,16 +31,30 @@ jobs:
3031
- name: Resolve Kubernetes Versions
3132
id: set-matrix
3233
run: |
34+
# 1. Fetch branches
3335
git ls-remote --heads https://github.com/kubernetes/kubernetes.git \
3436
| awk '{print $2}' | grep 'refs/heads/release-1.[0-9]*$' | sed 's|refs/heads/||' | sort -V > branches.txt
3537
36-
# 2. Determine Latest Release Branch (The highest number)
38+
# 2. Define variables
3739
LATEST_BRANCH=$(tail -n1 branches.txt)
38-
# 3. Min Supported Branch (e.g., currently 1.32)
39-
MIN_BRANCH="release-1.32"
40+
MIN_BRANCH="release-1.32"
4041
41-
echo "Latest: $LATEST_BRANCH, Min: $MIN_BRANCH"
42-
echo "matrix={\"k8s_branch\":[\"$LATEST_BRANCH\", \"$MIN_BRANCH\"]}" >> $GITHUB_OUTPUT
42+
# 3. Safety Check
43+
if [ -z "$LATEST_BRANCH" ]; then
44+
echo "Error: Could not find any release-1.xx branches!"
45+
exit 1
46+
fi
47+
48+
echo "Resolved -> Latest: $LATEST_BRANCH, Min: $MIN_BRANCH"
49+
50+
# 4. Generate JSON using jq
51+
MATRIX_JSON=$(jq -nc \
52+
--arg latest "$LATEST_BRANCH" \
53+
--arg min "$MIN_BRANCH" \
54+
'{"k8s_branch": [$latest, $min]}')
55+
56+
# 5. Output to GitHub Actions
57+
echo "matrix=$MATRIX_JSON" >> "$GITHUB_OUTPUT"
4358
4459
build-and-push:
4560
needs: resolve-versions
@@ -55,7 +70,6 @@ jobs:
5570
run: |
5671
sudo rm -rf /opt/hostedtoolcache || true
5772
docker system prune -af || true
58-
5973
- name: Checkout Kubernetes & Get the exact commit SHA
6074
uses: actions/checkout@v4
6175
with:
@@ -91,7 +105,6 @@ jobs:
91105
# Log in and Push
92106
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
93107
docker push $FULL_IMAGE
94-
95108
trigger-tests:
96109
needs: [resolve-versions, build-and-push]
97110
runs-on: ubuntu-latest
@@ -113,4 +126,4 @@ jobs:
113126
gh workflow run nightly-e2e.yml \
114127
--ref $branch \
115128
-f image_timestamp=$TIMESTAMP
116-
done
129+
done

0 commit comments

Comments
 (0)