From 878ef04aa8b37ed4ac33bcc75443bae9570190cb Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Thu, 7 Jul 2022 14:44:20 -0700 Subject: [PATCH 1/5] Fetch all git history in updateProduction job --- .github/workflows/finishReleaseCycle.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/finishReleaseCycle.yml b/.github/workflows/finishReleaseCycle.yml index 8c3d6b6f1dc5..3f7eb0ca3a86 100644 --- a/.github/workflows/finishReleaseCycle.yml +++ b/.github/workflows/finishReleaseCycle.yml @@ -59,6 +59,7 @@ jobs: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f with: ref: main + fetch-depth: 0 token: ${{ secrets.OS_BOTIFY_TOKEN }} - name: Update production branch From 7b33212eb96b0a243ca74fafe71087bdaefc413e Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Thu, 7 Jul 2022 15:01:45 -0700 Subject: [PATCH 2/5] Automatically resolve modify/delete conflict --- .github/actions/composite/updateProtectedBranch/action.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/actions/composite/updateProtectedBranch/action.yml b/.github/actions/composite/updateProtectedBranch/action.yml index 9c7b4ea0c8fb..b1ac7c278d5e 100644 --- a/.github/actions/composite/updateProtectedBranch/action.yml +++ b/.github/actions/composite/updateProtectedBranch/action.yml @@ -66,7 +66,9 @@ runs: git checkout ${{ inputs.TARGET_BRANCH }} BRANCH_NAME=update-${{ inputs.TARGET_BRANCH }}-from-${{ env.SOURCE_BRANCH }} git checkout -b "$BRANCH_NAME" - git merge -Xtheirs ${{ env.SOURCE_BRANCH }} + git merge -Xtheirs ${{ env.SOURCE_BRANCH }} \ + || git diff --name-only --diff-filter=U | xargs git rm \ + && git merge --continue git push --set-upstream origin "$BRANCH_NAME" - name: Create Pull Request From 2ad7a0d83d2c88c68dde15a275448f7bad07fc62 Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Thu, 7 Jul 2022 15:17:44 -0700 Subject: [PATCH 3/5] Use fetch in action to make it more robust --- .github/actions/composite/updateProtectedBranch/action.yml | 4 +++- .github/workflows/finishReleaseCycle.yml | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/actions/composite/updateProtectedBranch/action.yml b/.github/actions/composite/updateProtectedBranch/action.yml index b1ac7c278d5e..44bbfe8947a7 100644 --- a/.github/actions/composite/updateProtectedBranch/action.yml +++ b/.github/actions/composite/updateProtectedBranch/action.yml @@ -53,7 +53,9 @@ runs: - name: Checkout source branch shell: bash - run: git checkout ${{ env.SOURCE_BRANCH }} + run: | + git fetch + git checkout ${{ env.SOURCE_BRANCH }} - name: Set New Version shell: bash diff --git a/.github/workflows/finishReleaseCycle.yml b/.github/workflows/finishReleaseCycle.yml index 3f7eb0ca3a86..8c3d6b6f1dc5 100644 --- a/.github/workflows/finishReleaseCycle.yml +++ b/.github/workflows/finishReleaseCycle.yml @@ -59,7 +59,6 @@ jobs: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f with: ref: main - fetch-depth: 0 token: ${{ secrets.OS_BOTIFY_TOKEN }} - name: Update production branch From 0ec9cfdf3c91fe3513d3c88a835dba60b3b64836 Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Thu, 7 Jul 2022 15:19:35 -0700 Subject: [PATCH 4/5] Update tests to match new command --- tests/unit/getPullRequestsMergedBetweenTest.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/getPullRequestsMergedBetweenTest.sh b/tests/unit/getPullRequestsMergedBetweenTest.sh index 47e0e9d9c351..2aab142642f0 100755 --- a/tests/unit/getPullRequestsMergedBetweenTest.sh +++ b/tests/unit/getPullRequestsMergedBetweenTest.sh @@ -117,7 +117,7 @@ success "Version bumped to $(print_version) on main" info "Merging main into staging..." git checkout staging git checkout -b update-staging-from-main -git merge --no-edit -Xtheirs main +git merge --no-edit -Xtheirs main || git diff --name-only --diff-filter=U | xargs git rm && git merge --continue git checkout staging git merge update-staging-from-main --no-ff -m "Merge pull request #3 from Expensify/update-staging-from-main" info "Merged PR #3 to staging" @@ -219,7 +219,7 @@ title "Scenario #4A: Run the production deploy" info "Updating production from staging..." git checkout production git checkout -b update-production-from-staging -git merge --no-edit -Xtheirs staging +git merge --no-edit -Xtheirs staging || git diff --name-only --diff-filter=U | xargs git rm && git merge --continue git checkout production git merge update-production-from-staging --no-ff -m "Merge pull request #8 from Expensify/update-production-from-staging" info "Merged PR #8 into production" @@ -250,7 +250,7 @@ success "Successfully updated version to 1.1.0 on main!" info "Updating staging from main..." git checkout staging git checkout -b update-staging-from-main -git merge --no-edit -Xtheirs main +git merge --no-edit -Xtheirs main || git diff --name-only --diff-filter=U | xargs git rm && git merge --continue git checkout staging git merge update-staging-from-main --no-ff -m "Merge pull request #10 from Expensify/update-staging-from-main" info "Merged PR #10 into staging" @@ -299,7 +299,7 @@ success "Bumped version to 1.1.1 on main!" info "Merging main into staging..." git checkout staging git checkout -b update-staging-from-main -git merge --no-edit -Xtheirs main +git merge --no-edit -Xtheirs main || git diff --name-only --diff-filter=U | xargs git rm && git merge --continue git checkout staging git merge update-staging-from-main --no-ff -m "Merge pull request #13 from Expensify/update-staging-from-main" info "Merged PR #13 into staging" From 2de7310cbaf9a938fd9332a3bf33cf865f1990af Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Thu, 7 Jul 2022 15:40:20 -0700 Subject: [PATCH 5/5] Use command group instead of || followed by && --- .../actions/composite/updateProtectedBranch/action.yml | 7 ++++--- tests/unit/getPullRequestsMergedBetweenTest.sh | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/actions/composite/updateProtectedBranch/action.yml b/.github/actions/composite/updateProtectedBranch/action.yml index 44bbfe8947a7..892c6cd27eca 100644 --- a/.github/actions/composite/updateProtectedBranch/action.yml +++ b/.github/actions/composite/updateProtectedBranch/action.yml @@ -68,9 +68,10 @@ runs: git checkout ${{ inputs.TARGET_BRANCH }} BRANCH_NAME=update-${{ inputs.TARGET_BRANCH }}-from-${{ env.SOURCE_BRANCH }} git checkout -b "$BRANCH_NAME" - git merge -Xtheirs ${{ env.SOURCE_BRANCH }} \ - || git diff --name-only --diff-filter=U | xargs git rm \ - && git merge --continue + git merge -Xtheirs ${{ env.SOURCE_BRANCH }} || { + git diff --name-only --diff-filter=U | xargs git rm; + git merge --continue; + } git push --set-upstream origin "$BRANCH_NAME" - name: Create Pull Request diff --git a/tests/unit/getPullRequestsMergedBetweenTest.sh b/tests/unit/getPullRequestsMergedBetweenTest.sh index 2aab142642f0..84c29d333bff 100755 --- a/tests/unit/getPullRequestsMergedBetweenTest.sh +++ b/tests/unit/getPullRequestsMergedBetweenTest.sh @@ -117,7 +117,7 @@ success "Version bumped to $(print_version) on main" info "Merging main into staging..." git checkout staging git checkout -b update-staging-from-main -git merge --no-edit -Xtheirs main || git diff --name-only --diff-filter=U | xargs git rm && git merge --continue +git merge --no-edit -Xtheirs main || { git diff --name-only --diff-filter=U | xargs git rm; git merge --continue; } git checkout staging git merge update-staging-from-main --no-ff -m "Merge pull request #3 from Expensify/update-staging-from-main" info "Merged PR #3 to staging" @@ -219,7 +219,7 @@ title "Scenario #4A: Run the production deploy" info "Updating production from staging..." git checkout production git checkout -b update-production-from-staging -git merge --no-edit -Xtheirs staging || git diff --name-only --diff-filter=U | xargs git rm && git merge --continue +git merge --no-edit -Xtheirs staging || { git diff --name-only --diff-filter=U | xargs git rm; git merge --continue; } git checkout production git merge update-production-from-staging --no-ff -m "Merge pull request #8 from Expensify/update-production-from-staging" info "Merged PR #8 into production" @@ -250,7 +250,7 @@ success "Successfully updated version to 1.1.0 on main!" info "Updating staging from main..." git checkout staging git checkout -b update-staging-from-main -git merge --no-edit -Xtheirs main || git diff --name-only --diff-filter=U | xargs git rm && git merge --continue +git merge --no-edit -Xtheirs main || { git diff --name-only --diff-filter=U | xargs git rm; git merge --continue; } git checkout staging git merge update-staging-from-main --no-ff -m "Merge pull request #10 from Expensify/update-staging-from-main" info "Merged PR #10 into staging" @@ -299,7 +299,7 @@ success "Bumped version to 1.1.1 on main!" info "Merging main into staging..." git checkout staging git checkout -b update-staging-from-main -git merge --no-edit -Xtheirs main || git diff --name-only --diff-filter=U | xargs git rm && git merge --continue +git merge --no-edit -Xtheirs main || { git diff --name-only --diff-filter=U | xargs git rm; git merge --continue; } git checkout staging git merge update-staging-from-main --no-ff -m "Merge pull request #13 from Expensify/update-staging-from-main" info "Merged PR #13 into staging"