Skip to content

Commit 2eba65f

Browse files
committed
move action to workflow for better logging
1 parent febeb5c commit 2eba65f

File tree

2 files changed

+40
-7
lines changed

2 files changed

+40
-7
lines changed

.github/actions/sync-feature-branches/action.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ runs:
1111
steps:
1212
- name: Checkout repository
1313
uses: actions/checkout@v4
14-
with:
15-
fetch-depth: 0
1614

1715
- name: Set up Git
1816
shell: bash

.github/workflows/test-bed.yml

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,44 @@ jobs:
1212
test:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: Checkout sources
15+
- name: Checkout repository
1616
uses: actions/checkout@v4
17-
- name: Run GH action
18-
uses: ./.github/actions/sync-feature-branches
19-
with:
20-
disabled-feature-branches: 'test-main'
17+
18+
- name: Set up Git
19+
shell: bash
20+
run: |
21+
git config user.name aws-sdk-kotlin-ci
22+
git config user.email "[email protected]"
23+
24+
- name: Merge main into feature branches
25+
shell: bash
26+
run: |
27+
echo "Parsing disabled feature branches"
28+
unparsed_disabled_feature_branches="${{ inputs.disabled-feature-branches }}"
29+
IFS=',' read -r -a disabled_feature_branches <<< "$unparsed_disabled_feature_branches"
30+
for i in "${!disabled_feature_branches[@]}"; do
31+
disabled_feature_branches[i]=$(echo "${disabled_feature_branches[i]}" | xargs)
32+
echo "Found: $disabled_feature_branches[i]"
33+
done
34+
35+
git fetch --all
36+
37+
echo "Iterating through feature branches"
38+
for feature_branch in $(git branch -r --list "*-main"); do # TODO: ALL OF THESE WILL HAVE "origin/" in front of them
39+
echo "Found: $feature_branch"
40+
41+
for disabled_feature_branch in "${disabled_feature_branches[@]}"; do
42+
if [[ "$feature_branch" == "$disabled_feature_branch" ]]; then
43+
echo "Main will not be merged into $feature_branch because it was manually disabled"
44+
continue
45+
fi
46+
done
47+
48+
echo "Checking if $feature_branch is up to date with main"
49+
git checkout $feature_branch
50+
git fetch origin
51+
commits_behind=$(git rev-list --left-right --count main...$feature_branch | awk '{print $1})
52+
if [ "$commits_behind" -eq 0 ]; then
53+
echo "$feature_branch is 0 commits behind main. Skipping merge"
54+
continue
55+
fi

0 commit comments

Comments
 (0)