[bitnami/*] Do not execute tests for automatic PRs (#51282)

* [bitnami/*] Do not execute tests for automatic PRs

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

* Divide workflows

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

---------

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>
This commit is contained in:
Jose Antonio Carmona 2023-10-09 14:20:31 +02:00 committed by GitHub
parent d239896e89
commit 6424bfae82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 61 additions and 49 deletions

56
.github/workflows/auto-pr-review.yml vendored Normal file
View File

@ -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.

View File

@ -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.