From 1567add4947175eec6d4161de3b5c54b569a12ac Mon Sep 17 00:00:00 2001 From: 0marperez Date: Tue, 18 Mar 2025 10:17:30 -0400 Subject: [PATCH 1/7] fix: gracefully handle merge conflicts in main to feature branches action --- .github/actions/merge-main/action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/actions/merge-main/action.yml b/.github/actions/merge-main/action.yml index 4ba29ba..1a3ec48 100644 --- a/.github/actions/merge-main/action.yml +++ b/.github/actions/merge-main/action.yml @@ -90,8 +90,7 @@ runs: echo "...switching to branch: $branch" git switch "$branch" echo "...merging main" - git merge -m "misc: merge from main" origin/main - if [ $? -eq 0 ]; then + if git merge -m "misc: merge from main" origin/main; then echo "...pushing to origin" git push origin "$branch" else From 7247b99c639600abf195525b253e5929aeec0600 Mon Sep 17 00:00:00 2001 From: 0marperez Date: Tue, 18 Mar 2025 10:20:10 -0400 Subject: [PATCH 2/7] misc: run test --- .github/workflows/merge-main.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/merge-main.yml b/.github/workflows/merge-main.yml index 560876b..2d6dbea 100644 --- a/.github/workflows/merge-main.yml +++ b/.github/workflows/merge-main.yml @@ -3,12 +3,23 @@ on: schedule: - cron: "0 7 * * 1-5" # At 07:00 UTC (00:00 PST, 03:00 EST), Monday through Friday workflow_dispatch: + # TODO: REMOVE v + push: + branches: + - main + - '*-main' + pull_request: + branches: + - main + - '*-main' + # TODO: REMOVE ^ jobs: test: runs-on: ubuntu-latest steps: - name: Merge main - uses: awslabs/aws-kotlin-repo-tools/.github/actions/merge-main@main + uses: awslabs/aws-kotlin-repo-tools/.github/actions/merge-main@fix-merge-mn + # TODO: Use main instead of feature branch ^ with: exempt-branches: # Add any if required \ No newline at end of file From 5702b7dbd6d5bdeefc6c4dd43beb2b13603ac546 Mon Sep 17 00:00:00 2001 From: 0marperez Date: Tue, 18 Mar 2025 10:23:41 -0400 Subject: [PATCH 3/7] fix: rename step --- .github/workflows/merge-main.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/merge-main.yml b/.github/workflows/merge-main.yml index 2d6dbea..96e74c1 100644 --- a/.github/workflows/merge-main.yml +++ b/.github/workflows/merge-main.yml @@ -3,23 +3,12 @@ on: schedule: - cron: "0 7 * * 1-5" # At 07:00 UTC (00:00 PST, 03:00 EST), Monday through Friday workflow_dispatch: - # TODO: REMOVE v - push: - branches: - - main - - '*-main' - pull_request: - branches: - - main - - '*-main' - # TODO: REMOVE ^ jobs: - test: + merge: runs-on: ubuntu-latest steps: - name: Merge main - uses: awslabs/aws-kotlin-repo-tools/.github/actions/merge-main@fix-merge-mn - # TODO: Use main instead of feature branch ^ + uses: awslabs/aws-kotlin-repo-tools/.github/actions/merge-main@main with: exempt-branches: # Add any if required \ No newline at end of file From 7acec728b91f2031acf0f2cf0322cb72837bfffe Mon Sep 17 00:00:00 2001 From: 0marperez Date: Tue, 18 Mar 2025 10:38:20 -0400 Subject: [PATCH 4/7] feat: fail action on failed merge --- .github/actions/merge-main/action.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/actions/merge-main/action.yml b/.github/actions/merge-main/action.yml index 1a3ec48..a347d25 100644 --- a/.github/actions/merge-main/action.yml +++ b/.github/actions/merge-main/action.yml @@ -86,6 +86,8 @@ runs: return fi + failed="false" + for branch in "${branches[@]}"; do echo "...switching to branch: $branch" git switch "$branch" @@ -95,9 +97,14 @@ runs: git push origin "$branch" else echo "...merge failed" + failed="true" git merge --abort fi done + + if [ "$failed" == "true" ]; then + exit -1 + fi } merge_main \ No newline at end of file From c7945f5aa2e4ab366475fb6ceddb29321bd919bf Mon Sep 17 00:00:00 2001 From: 0marperez Date: Tue, 18 Mar 2025 10:42:36 -0400 Subject: [PATCH 5/7] fix: use correct exit code --- .github/actions/merge-main/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/merge-main/action.yml b/.github/actions/merge-main/action.yml index a347d25..5836c16 100644 --- a/.github/actions/merge-main/action.yml +++ b/.github/actions/merge-main/action.yml @@ -103,7 +103,7 @@ runs: done if [ "$failed" == "true" ]; then - exit -1 + exit 1 fi } From eec2744f2e148e95cfdaa6c98de014bfac0117ae Mon Sep 17 00:00:00 2001 From: 0marperez Date: Tue, 18 Mar 2025 10:43:09 -0400 Subject: [PATCH 6/7] fix: clean diff --- .github/workflows/merge-main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/merge-main.yml b/.github/workflows/merge-main.yml index 96e74c1..560876b 100644 --- a/.github/workflows/merge-main.yml +++ b/.github/workflows/merge-main.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: jobs: - merge: + test: runs-on: ubuntu-latest steps: - name: Merge main From 40bd2cd28f576e0e259a10d2911561e9708ed621 Mon Sep 17 00:00:00 2001 From: 0marperez Date: Tue, 18 Mar 2025 10:45:53 -0400 Subject: [PATCH 7/7] misc: sign last commit