add input to workflow #9
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: "" | |
| 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: | | |
| echo "Parsing disabled feature branches" | |
| unparsed_disabled_feature_branches="${{ inputs.disabled-feature-branches }}" | |
| IFS=',' read -r -a disabled_feature_branches <<< "$unparsed_disabled_feature_branches" | |
| for i in "${!disabled_feature_branches[@]}"; do | |
| disabled_feature_branches[i]=$(echo "${disabled_feature_branches[i]}" | xargs) | |
| echo "Found: $disabled_feature_branches[i]" | |
| done | |
| git fetch --all | |
| echo "Iterating through feature branches" | |
| for feature_branch in $(git branch -r --list "*-main"); do # TODO: ALL OF THESE WILL HAVE "origin/" in front of them | |
| 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 |