From a379ec20b1e4ff7d3178cc6cac4050b19a0c7991 Mon Sep 17 00:00:00 2001 From: Fran Mulero Date: Tue, 19 Jul 2022 13:52:51 +0200 Subject: [PATCH] [bitnami/*] Add automated approval for bitnami-bot PRs (#25) * Add automatic approval for bitnami-bot PRs if all checks passed OK Signed-off-by: Fran Mulero * Remove ci-scheduled- pipeline. It doesn't make sense anymore Signed-off-by: Fran Mulero --- .github/workflows/ci-pipeline.yaml | 48 ++++++++++++++- .github/workflows/ci-scheduled-pipeline.yaml | 65 -------------------- README.md | 2 - 3 files changed, 47 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/ci-scheduled-pipeline.yaml diff --git a/.github/workflows/ci-pipeline.yaml b/.github/workflows/ci-pipeline.yaml index ad079eaa6403..6ff1c55ebecb 100644 --- a/.github/workflows/ci-pipeline.yaml +++ b/.github/workflows/ci-pipeline.yaml @@ -90,4 +90,50 @@ jobs: VIB_ENV_PATH: ${{ matrix.flavor }} # Container name VIB_ENV_CONTAINER: ${{ needs.get-container.outputs.container }} - VIB_ENV_TAG: ${{ steps.get-tag.outputs.tag }} \ No newline at end of file + VIB_ENV_TAG: ${{ steps.get-tag.outputs.tag }} + ci-pr-review: + runs-on: ubuntu-latest + needs: vib-verify + name: Reviewal for automated PRs + if: | + always() && + github.actor == 'bitnami-bot' && + contains(github.event.pull_request.labels.*.name, 'auto-merge') + steps: + # Approves 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: Approval + if: ${{ needs.vib-verify.result == 'success' }} + run: | + curl --request POST \ + --url https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews \ + --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header 'content-type: application/json' \ + --data '{ + "event": "APPROVE" + }' \ + --fail + # Removes "auto-merge" label and add related agents as reviewers if the 'VIB Verify' job failed + - name: Manual review required + if: ${{ needs.vib-verify.result == 'failure' }} + run: | + curl --request DELETE \ + --url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/auto-merge \ + --header 'authorization: Bearer ${{ secrets.BITNAMI_BOT_TOKEN }}' \ + --fail + curl --request POST \ + --url https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \ + --header 'authorization: Bearer ${{ secrets.BITNAMI_BOT_TOKEN }}' \ + --header 'content-type: application/json' \ + --data '{ + "body": "There has been an error during the automated release process. Manual revision is now required." + }' \ + --fail + curl --request POST \ + --url https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/requested_reviewers \ + --header 'authorization: Bearer ${{ secrets.BITNAMI_BOT_TOKEN }}' \ + --header 'content-type: application/json' \ + --data '{ + "reviewers": ["fmulero"] + }' \ + --fail diff --git a/.github/workflows/ci-scheduled-pipeline.yaml b/.github/workflows/ci-scheduled-pipeline.yaml deleted file mode 100644 index 65e8f7bdfe5e..000000000000 --- a/.github/workflows/ci-scheduled-pipeline.yaml +++ /dev/null @@ -1,65 +0,0 @@ -name: Scheduled CI pipeline -on: - schedule: - - cron: "?/15 * * * *" - workflow_dispatch: - inputs: - container: - description: Force VIB verification with this container - required: false -env: - CSP_API_URL: https://console.cloud.vmware.com - CSP_API_TOKEN: ${{ secrets.CSP_API_TOKEN }} - VIB_PUBLIC_URL: https://cp.bromelia.vmware.com -jobs: - get-container: - runs-on: ubuntu-latest - name: Get random container - outputs: - container: ${{ steps.get-container.outputs.container }} - flavors: ${{ steps.get-container.outputs.flavors }} - steps: - - uses: actions/checkout@v3 - name: Checkout Repository - with: - fetch-depth: 0 - - id: get-container - name: Get random container - run: | - container_name="${{ github.event.inputs.container }}" - if [ -z "$container_name" ]; then - containers=(bitnami/*) - random_index=$(( $RANDOM % ${#containers[@]} )) - container_name=$(echo "${containers[$random_index]}" | sed "s|bitnami/||g") - fi - flavors=(bitnami/${container_name}/*/*/) - flavors_json="[" - for flavor in "${flavors[@]}"; do - tag="$(git log --pretty=tformat:"%s" -n 1 --grep=" release$" --author bitnami-bot@vmware.com --author containers@bitnami.com --author containers-bot@bitnami.com -- ${flavor} | awk '{print $1}')" - flavors_json+="{\"path\": \"${flavor}\", \"tag\": \"${tag}\"}," - done; - flavors_json="${flavors_json/%,/]}" - - echo "::set-output name=container::${container_name}" - echo "::set-output name=flavors::${flavors_json}" - vib-verify: - runs-on: ubuntu-latest - needs: get-container - name: Verify - strategy: - fail-fast: false - matrix: - flavor: ${{ fromJSON(needs.get-container.outputs.flavors) }} - steps: - - uses: actions/checkout@v3 - name: Checkout Repository - - uses: vmware-labs/vmware-image-builder-action@main - name: Verify ${{ needs.get-container.outputs.container }} - with: - pipeline: vib-verify.json - env: - # Path with docker resources - VIB_ENV_PATH: ${{ matrix.flavor.path }} - # Container name - VIB_ENV_CONTAINER: ${{ needs.get-container.outputs.container }} - VIB_ENV_TAG: ${{ matrix.flavor.tag }} \ No newline at end of file diff --git a/README.md b/README.md index 372f425484a4..5e7c1f9e022a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -[![Scheduled CI pipeline](https://github.com/bitnami/containers/actions/workflows/ci-scheduled-pipeline.yaml/badge.svg)](https://github.com/bitnami/containers/actions/workflows/ci-scheduled-pipeline.yaml) - # Bitnami Containers Bitnami is currently working on unifying all container sources repositories into a single location. In the meantime, it will be synchronized in a daily manner to receive all the updates from the other repositories.