[bitnami/*] Migrate logic for automated PRs to GitHub's CI (#339)

* [bitnami/*] Migrate logic for automated PRs to GitHub's CI

Signed-off-by: FraPazGal <fdepaz@vmware.com>

* Use labeler action and improve readability

Signed-off-by: FraPazGal <fdepaz@vmware.com>
This commit is contained in:
Francisco de Paz Galán 2022-07-26 13:26:50 +02:00 committed by GitHub
parent 0594567b6e
commit a9e85d0802
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 43 additions and 7 deletions

View File

@ -14,6 +14,32 @@ env:
CSP_API_TOKEN: ${{ secrets.CSP_API_TOKEN }}
VIB_PUBLIC_URL: https://cp.bromelia.vmware.com
jobs:
auto-pr-triage:
runs-on: ubuntu-latest
name: Triage for automated PRs
if: |
contains(github.event.pull_request.title, 'Release') &&
github.event.action == 'opened' &&
github.actor == 'bitnami-bot'
steps:
# Enables auto-merge and adds necessary labels for automated releases' PRs
- id: labeling
name: Label PR
uses: andymckay/labeler@1.0.4
with:
# We can't use GITHUB_TOKEN because the labeling needs to trigger a new CI pipeline
repo-token: "${{ secrets.BITNAMI_BOT_TOKEN }}"
add-labels: "verify, auto-merge"
- id: auto-merge
name: Enable auto-merge
run: |
curl --request POST \
--url https://api.github.com/graphql \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--data '{
"query": "mutation { enablePullRequestAutoMerge(input: {pullRequestId: \"${{ github.event.pull_request.node_id }}\", mergeMethod: SQUASH}) { clientMutationId }}"
}' \
--fail
get-container:
runs-on: ubuntu-latest
name: Get modified containers
@ -113,7 +139,7 @@ jobs:
# Container name
VIB_ENV_CONTAINER: ${{ needs.get-container.outputs.container }}
VIB_ENV_TAG: ${{ steps.get-tag.outputs.tag }}
ci-pr-review:
auto-pr-review:
runs-on: ubuntu-latest
needs: vib-verify
name: Reviewal for automated PRs
@ -135,17 +161,27 @@ jobs:
"event": "APPROVE"
}' \
--fail
# Removes "auto-merge" label and add related agents as reviewers if the 'VIB Verify' job failed
- name: Remove auto-merge label
if: ${{ needs.vib-verify.result == 'failure' }}
uses: andymckay/labeler@1.0.4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
remove-labels: "auto-merge"
- name: Disable auto-merge
run: |
curl --request POST \
--url https://api.github.com/graphql \
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--data '{
"query": "mutation { disablePullRequestAutoMerge(input: {pullRequestId: \"${{ github.event.pull_request.node_id }}\"}) { clientMutationId }}"
}' \
--fail
- 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 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"body": "There has been an error during the automated release process. Manual revision is now required."