From 7a0ea47a697c402580938aadc218af71571510c8 Mon Sep 17 00:00:00 2001 From: Fran Mulero Date: Wed, 14 Dec 2022 08:28:33 +0100 Subject: [PATCH] [bitnami/*] Merge automated PRs instead of enabling auto-merge (#16824) [bitnami/*] Merge automated PRs once tests run ok Signed-off-by: Fran Mulero --- .github/workflows/ci-pipeline.yml | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 4ead4716df45..c95378bb85eb 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -165,21 +165,33 @@ jobs: contains(github.event.pull_request.labels.*.name, 'auto-merge') && github.event.pull_request.user.login == 'bitnami-bot' steps: - - name: Enable auto-merge feature - if: ${{ needs.verification-summary.outputs.result == 'success' }} - uses: reitermarkus/automerge@v2.2.0 - with: - # Necessary to trigger CD workflow - token: ${{ secrets.BITNAMI_BOT_TOKEN }} - merge-method: squash - pull-request: ${{ github.event.number }} + # Approve the CI's PR if the 'VIB Verify' job succeeded + # Approved by the 'github-actions' user; a PR can't be approved by its author - name: PR Approval if: ${{ needs.verification-summary.outputs.result == 'success' }} uses: hmarr/auto-approve-action@v3.0.0 with: pull-request-number: ${{ github.event.number }} + - name: Merge + id: merge + if: ${{ needs.verification-summary.outputs.result == 'success' }} + uses: actions/github-script@v6 + with: + result-encoding: string + retries: 3 + # Necessary to trigger CD workflows + github-token: ${{ secrets.BITNAMI_BOT_TOKEN }} + script: | + github.rest.pulls.merge({ + pull_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + merge_method: 'squash' + }) + # If the CI did not succeed ('VIB Verify' failed or skipped), + # post a comment on the PR and assign a maintainer agent to review it - name: Manual review required - if: ${{ needs.verification-summary.outputs.result != 'success' }} + if: ${{ always() && (needs.verification-summary.outputs.result != 'success' || steps.merge.outcome != 'success') }} uses: peter-evans/create-or-update-comment@v2.0.0 with: issue-number: ${{ github.event.number }}