Skip to content

Commit 94771d3

Browse files
committed
github actions: Trigger clk-rebase workflow when stable branches are updated
Use repository_dispatch to trigger clk-rebase.yml only when sync.yml actually pushes updates to stable_* branches.
1 parent 4092c6f commit 94771d3

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

.github/workflows/clk-rebase.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: CLK Rebase
22
on:
33
workflow_dispatch:
4+
repository_dispatch:
5+
types:
6+
- stable-branch-updated
47
push:
58
branches:
6-
- stable_6.*.y
79
- clk-rebase-ga
810

911
jobs:
@@ -14,10 +16,9 @@ jobs:
1416
options: --cpus 8 --privileged
1517
env:
1618
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17-
# For push events, use the branch that triggered the workflow
18-
# For manual dispatch, default to stable_6.12.y
19-
#STABLE_TRACKING_BRANCH: ${{ github.ref_name || 'stable_6.12.y' }}
20-
STABLE_TRACKING_BRANCH: ${{ 'stable_6.12.y' }}
19+
# For repository_dispatch events, use the branch from the payload
20+
# For push/manual dispatch to clk-rebase-ga or workflow_dispatch, default to stable_6.18.y
21+
STABLE_TRACKING_BRANCH: ${{ github.event.client_payload.branch || (startsWith(github.ref_name, 'stable_') && github.ref_name) || 'stable_6.18.y' }}
2122
steps:
2223
- name: Set version variables
2324
run: |

.github/workflows/sync.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,30 @@ jobs:
5454
5555
git remote add upstream ${REMOTE}
5656
git fetch upstream --tags --quiet
57+
58+
# Check if rebase will make changes
59+
BEFORE_SHA=$(git rev-parse HEAD)
5760
git rebase upstream/${REMOTE_BRANCH}
58-
git push origin --follow-tags
61+
AFTER_SHA=$(git rev-parse HEAD)
62+
63+
if [ "$BEFORE_SHA" != "$AFTER_SHA" ]; then
64+
echo "Changes detected, pushing..."
65+
git push origin --follow-tags
66+
echo "CHANGES_PUSHED=true" >> $GITHUB_ENV
67+
else
68+
echo "No changes to push"
69+
echo "CHANGES_PUSHED=false" >> $GITHUB_ENV
70+
fi
71+
72+
- name: Trigger CLK rebase workflow
73+
if: env.CHANGES_PUSHED == 'true' && startsWith(matrix.branch, 'stable_')
74+
run: |
75+
curl -L \
76+
-X POST \
77+
-H "Accept: application/vnd.github+json" \
78+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
79+
-H "X-GitHub-Api-Version: 2022-11-28" \
80+
https://api.github.com/repos/${{ github.repository }}/dispatches \
81+
-d "{\"event_type\":\"stable-branch-updated\",\"client_payload\":{\"branch\":\"${{ matrix.branch }}\"}}"
5982
6083

0 commit comments

Comments
 (0)