From d7078f2aada41a8a583d2b37eb0021b24a9af7cc Mon Sep 17 00:00:00 2001 From: Omkar Khatavkar Date: Thu, 15 Dec 2022 17:59:51 +0530 Subject: [PATCH] added support to auto-merge the auto-cherry-pick pr (#10372) added support to automerge the autocherry pick pr --- .github/workflows/automerge.yaml | 62 ++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .github/workflows/automerge.yaml diff --git a/.github/workflows/automerge.yaml b/.github/workflows/automerge.yaml new file mode 100644 index 00000000000..ae03a34f55b --- /dev/null +++ b/.github/workflows/automerge.yaml @@ -0,0 +1,62 @@ +name: automerge auto-cherry-picked pr's +on: + pull_request_target: + types: + - labeled + - unlabeled + - edited + - ready_for_review + branches-ignore: + - master + issue_comment: + types: + - created + - deleted + pull_request_review: + types: + - submitted + check_suite: + types: + - completed + +jobs: + automerge: + name: Automerge auto-cherry-picked pr + if: contains(github.event.pull_request.labels.*.name, 'AutoMerge_Cherry_Picked') + runs-on: ubuntu-latest + steps: + - id: find-prt-comment + name: Find the prt comment + uses: peter-evans/find-comment@v2 + with: + issue-number: ${{ github.event.number }} + body-includes: "trigger: test-robottelo" + direction: last + + - name: Fail automerge if PRT was not initiated + if: steps.find-prt-comment.outputs.comment-body == "" + run: | + echo "::error PRT comment not added the PR" + + - name: Wait for PRT checks to get initiated + run: | + if [ "${{ github.event_name }}" == "issue_comment" ]; then + echo "Waiting for 5 min, PRT to be initiated." && sleep 300 + fi + + - id: automerge + name: Auto merge of cherry-picked PRs. + uses: "pascalgn/automerge-action@v0.15.5" + env: + GITHUB_TOKEN: "${{ secrets.CHERRYPICK_PAT }}" + MERGE_LABELS: "AutoMerge_Cherry_Picked, Auto_Cherry_Picked" + MERGE_METHOD: "squash" + MERGE_RETRIES: 5 + MERGE_RETRY_SLEEP: 900000 + + - name: Auto Merge Status + run: | + if [ "${{ steps.automerge.outputs.mergeResult }}" == 'merged' ]; then + echo "Pull request ${{ steps.automerge.outputs.pullRequestNumber }} is Auto Merged !" + else + echo "::error Auto Merge of Pull request ${{ steps.automerge.outputs.pullRequestNumber }} is ${{steps.automerge.outputs.mergeResult}} !"