diff --git a/.github/workflows/cherryPick.yml b/.github/workflows/cherryPick.yml index b3d1ad81d304..db76a651b818 100644 --- a/.github/workflows/cherryPick.yml +++ b/.github/workflows/cherryPick.yml @@ -100,20 +100,25 @@ jobs: USER: OSBotify TITLE_REGEX: Update version to ${{ env.NEW_VERSION }} - - name: Cherry-pick the merge commits to new branch - id: cherryPick + - name: Cherry-pick the version-bump to new branch run: | git fetch - git cherry-pick ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }} ${{ steps.getVersionBumpMergeCommit.outputs.MERGE_COMMIT_SHA }} --mainline 1 - continue-on-error: true + git cherry-pick -x --mainline 1 --strategy=recursive -Xtheirs ${{ steps.getVersionBumpMergeCommit.outputs.MERGE_COMMIT_SHA }} - # If there is a merge conflict, we'll just commit what we have, - # and the PR will be auto-assigned for someone to manually resolve the conflicts. - - name: If there is a merge conflict... - if: ${{ steps.cherryPick.outcome == 'failure' }} + - name: Cherry-pick the merge commit of target PR to new branch + id: cherryPick run: | - git add -A - git cherry-pick --continue + echo "Attempting to cherry-pick ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }}" + if git cherry-pick -x --mainline 1 ${{ steps.getCPMergeCommit.outputs.MERGE_COMMIT_SHA }}; then + echo "🎉 No conflicts! CP was a success, PR can be automerged 🎉" + echo "::set-output name=SHOULD_AUTOMERGE::true" + else + echo "😞 PR can't be automerged, there are merge conflicts in the following files:" + git --no-pager diff --name-only --diff-filter=U + git add . + GIT_MERGE_AUTOEDIT=no git cherry-pick --continue + echo "::set-output name=SHOULD_AUTOMERGE::false" + fi - name: Create Pull Request id: createPullRequest @@ -135,7 +140,7 @@ jobs: PULL_REQUEST_NUMBER: ${{ steps.createPullRequest.outputs.pr_number }} - name: Auto-assign PR if there are merge conflicts - if: ${{ steps.cherryPick.outcome == 'failure' || steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'false' }} + if: ${{ steps.cherryPick.outputs.SHOULD_AUTOMERGE == 'false' || steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'false' }} uses: actions-ecosystem/action-add-labels@a8ae047fee0ca28235f9764e1c478d2136dc15c1 with: number: ${{ steps.createPullRequest.outputs.pr_number }} @@ -144,7 +149,7 @@ jobs: Hourly - name: If PR has merge conflicts, comment with instructions for assignee - if: ${{ steps.cherryPick.outcome == 'failure' || steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'false' }} + if: ${{ steps.cherryPick.outputs.SHOULD_AUTOMERGE == 'false' || steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'false' }} uses: actions-ecosystem/action-create-comment@cd098164398331c50e7dfdd0dfa1b564a1873fac with: github_token: ${{ secrets.OS_BOTIFY_TOKEN }} @@ -157,7 +162,7 @@ jobs: # TODO: Once https://github.com/hmarr/auto-approve-action/pull/186 is merged, point back at the non-forked repo - name: Check for an auto approve # Important: only auto-approve if there was no merge conflict! - if: ${{ steps.cherryPick.outcome == 'success' && steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'true' }} + if: ${{ steps.cherryPick.outputs.SHOULD_AUTOMERGE == 'true' && steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'true' }} # Version: 2.0.0 uses: roryabraham/auto-approve-action@6bb4a3dcf07664d0131e1c74a4bc6d0d8c849978 with: @@ -166,7 +171,7 @@ jobs: - name: Check for an auto merge # Important: only auto-merge if there was no merge conflict! - if: ${{ steps.cherryPick.outcome == 'success' && steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'true' }} + if: ${{ steps.cherryPick.outputs.SHOULD_AUTOMERGE == 'true' && steps.isPullRequestMergeable.outputs.IS_MERGEABLE == 'true' }} # Version: 0.12.0 uses: pascalgn/automerge-action@39d831e1bb389bd242626bc25d4060064a97181c env: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9d64d644793e..0865485bcbf2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,13 +13,14 @@ jobs: steps: - name: Get merged pull request id: getMergedPullRequest - uses: actions-ecosystem/action-get-merged-pull-request@59afe90821bb0b555082ce8ff1e36b03f91553d9 + # TODO: Point back action actions-ecosystem after https://github.com/actions-ecosystem/action-get-merged-pull-request/pull/223 is merged + uses: roryabraham/action-get-merged-pull-request@7a7a194f6ff8f3eef58c822083695a97314ebec1 with: github_token: ${{ secrets.GITHUB_TOKEN }} - name: Check if merged pull request was an automatic version bump PR id: isAutomatedPullRequest - run: echo "::set-output name=IS_AUTOMERGE_PR::${{ github.actor == 'OSBotify' }}" + run: echo "::set-output name=IS_AUTOMERGE_PR::${{ steps.getMergedPullRequest.outputs.author == 'OSBotify' }}" deployStaging: runs-on: ubuntu-latest