From 6424bfae82b87fa9a1055c07da6d3f53c44765bc Mon Sep 17 00:00:00 2001 From: Jose Antonio Carmona Date: Mon, 9 Oct 2023 14:20:31 +0200 Subject: [PATCH] [bitnami/*] Do not execute tests for automatic PRs (#51282) * [bitnami/*] Do not execute tests for automatic PRs Signed-off-by: Jose Antonio Carmona * Divide workflows Signed-off-by: Jose Antonio Carmona --------- Signed-off-by: Jose Antonio Carmona --- .github/workflows/auto-pr-review.yml | 56 ++++++++++++++++++++++++++++ .github/workflows/ci-pipeline.yml | 54 +++------------------------ 2 files changed, 61 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/auto-pr-review.yml diff --git a/.github/workflows/auto-pr-review.yml b/.github/workflows/auto-pr-review.yml new file mode 100644 index 000000000000..dc48fbf0e129 --- /dev/null +++ b/.github/workflows/auto-pr-review.yml @@ -0,0 +1,56 @@ +name: '[CI/CD] Automatic PR Review' +on: # rebuild any PRs and main branch changes + pull_request_target: + types: + - synchronize + - labeled + branches: + - main + - bitnami:main +permissions: {} +# Avoid concurrency over the same PR +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} +jobs: + auto-pr-review: + runs-on: ubuntu-latest + name: Reviewal for automated PRs + permissions: + pull-requests: write + # This job will be executed when the PR was created by bitnami-bot and it has the 'auto-merge' label + if: | + contains(github.event.pull_request.labels.*.name, 'auto-merge') && + github.event.pull_request.user.login == 'bitnami-bot' + steps: + # Approve the CI's PR automatically, as it has been tested in our internal pipeline already + # Approved by the 'github-actions' user; a PR can't be approved by its author + - name: PR Approval + uses: hmarr/auto-approve-action@v3.0.0 + with: + pull-request-number: ${{ github.event.number }} + - name: Merge + id: merge + 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 merge process did not succeed, + # post a comment on the PR and assign a maintainer agent to review it + - name: Manual review required + if: ${{ always() && steps.merge.outcome != 'success' }} + uses: peter-evans/create-or-update-comment@v3.0.0 + with: + issue-number: ${{ github.event.number }} + # Necessary to trigger support workflows + token: ${{ secrets.BITNAMI_BOT_TOKEN }} + body: | + There has been an error during the automated release process. Manual revision is now required. diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 46ea72582352..44822b003e90 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -56,7 +56,10 @@ jobs: vib-verify: runs-on: ubuntu-latest needs: get-containers - if: ${{ needs.get-containers.outputs.result == 'ok' }} + # Automatic PRs do not need to be re-tested in GitHub + if: | + needs.get-containers.outputs.result == 'ok' && + github.event.pull_request.user.login != 'bitnami-bot' name: VIB Verify permissions: contents: read @@ -127,7 +130,7 @@ jobs: - vib-verify outputs: result: ${{ steps.get-status.outputs.result }} - if: ${{ always() }} + if: ${{ always() && github.event.pull_request.user.login != 'bitnami-bot' }} steps: - id: get-status name: Check Status @@ -166,50 +169,3 @@ jobs: core.setFailed(error.message) } return state - auto-pr-review: - runs-on: ubuntu-latest - name: Reviewal for automated PRs - permissions: - pull-requests: write - needs: verification-summary - # This job will be executed when the PR was created by bitnami-bot and it has the 'auto-merge' label - if: | - always() && - contains(github.event.pull_request.labels.*.name, 'auto-merge') && - github.event.pull_request.user.login == 'bitnami-bot' - steps: - # 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: ${{ always() && (needs.verification-summary.outputs.result != 'success' || steps.merge.outcome != 'success') }} - uses: peter-evans/create-or-update-comment@v3.0.0 - with: - issue-number: ${{ github.event.number }} - # Necessary to trigger support workflows - token: ${{ secrets.BITNAMI_BOT_TOKEN }} - body: | - There has been an error during the automated release process. Manual revision is now required. - Please check the related [action_run#${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more information.