Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automation/6261 chanel qa approval before pr merge workflow #8575

Closed
Closed
67 changes: 67 additions & 0 deletions .github/workflows/pr_checks_for_qa_approvals.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

#
# Checks if QA approvals are necessary, and if so runs the associated action when a new review is added
#

name: '[Utils] QA required approval'

on:
pull_request:
types: [opened, edited]
pull_request_review:
types: [submitted, dismissed]
push:

jobs:
check_for_qa_required:
if: github.event.review.state == 'APPROVED'
runs-on: ubuntu-latest
outputs:
requires_qa: ${{ steps.qa_required.outputs.requires_qa}}
steps:
- uses: dorny/paths-filter@v2
id: qa_required
with:
filters: |
requires_qa:
- 'VAMobile/src'
- 'VAMobile/package.json'
- '!VAMobile/src/*.test.*'
check_for_qa_approval:
runs-on: ubuntu-latest
needs: check_for_qa_required
outputs:
has_qa_approval: ${{ steps.check-qa-approval.outputs.has_qa_approval }}
steps:
- name: Check QA approval
id: check-qa-approval
shell: bash
if: ${{ needs.check_for_qa_required.outputs.requires_qa }} == 'true'
run: |
token=${{ secrets.GITHUB_TOKEN }}
base64AuthInfo='$token | base64 -e'
response=$(curl --request GET \
--url https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews \
--header 'Authorization: $base64AuthInfo' \
--header 'Content-Type: application/json')
approvals = $response | jq '.[] | select(.state=="APPROVED")'
echo $approvals
if $aprovals.length > 1
qa_approvals = $approvals | jq '.[] | select(.user.login | IN("rbontrager","DJUltraTom","TKDickson"))'
if $qa_approvals.length > 0
echo 'This PR has QA approval to merge'
echo ::set-output name=has_qa_approval::'true'
else
echo 'This PR requires QA approval to merge'
echo ::set-output name=has_qa_approval::'false'
fi
else
echo 'This PR requires 2 approvals, including one QA approval, before merging.'
echo ::set-output name=has_qa_approval::'false'
fi
add_or_remove_qa_required_label:
name: Add or Remove label
needs: check_for_qa_approval
runs-on: ubuntu-latest
env:
LABEL: qa-review-required
Loading