Skip to content

logging

logging #14

Workflow file for this run

name: Testing new GH action
on:
push:
branches:
- '**'
- '!main'
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
disabled-feature-branches:
# GH doesn't have list inputs so we're using a string
description: Feature branches for which syncing will be disabled, separated by comma (e.g. feat-1-main,feat-2-main)
default: "feat-1-main"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Git
shell: bash
run: |
git config user.name aws-sdk-kotlin-ci
git config user.email "[email protected]"
- name: Merge main into feature branches
shell: bash
run: |
unparsed_disabled_feature_branches="${{ inputs.disabled-feature-branches }}"
echo "Unparsed disabled feature branches: $unparsed_disabled_feature_branches"
echo "Parsing disabled feature branches"
IFS=',' read -r -a disabled_feature_branches <<< "$unparsed_disabled_feature_branches"
for i in "${!disabled_feature_branches[@]}"; do
echo "Parsing branch ${disabled_feature_branches[i]}"
disabled_feature_branches[i]=$(echo "${disabled_feature_branches[i]}" | xargs)
echo "Found: $disabled_feature_branches[i]"
done
echo "Done parsing feature branches"
echo "Fetching all"
git fetch --all
echo "Done fetching all"
echo "Iterating through feature branches"
for feature_branch in $(git branch -r --list "*-main"); do
echo "Found: $feature_branch"
for disabled_feature_branch in "${disabled_feature_branches[@]}"; do
if [[ "$feature_branch" == "$disabled_feature_branch" ]]; then
echo "Main will not be merged into $feature_branch because it was manually disabled"
continue
fi
done
echo "Checking if $feature_branch is up to date with main"
git checkout $feature_branch
git fetch origin
commits_behind=$(git rev-list --left-right --count main...$feature_branch | awk '{print $1})
if [ "$commits_behind" -eq 0 ]; then
echo "$feature_branch is 0 commits behind main. Skipping merge"
continue
fi