Skip to content

Try lowercase branch name #4

Try lowercase branch name

Try lowercase branch name #4

#
# 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, converted_to_draft, ready_for_review, reopened]
#paths:
#- 'VAMobile/src/**'
#- 'VAMobile/package.json'
#- '!VAMobile/src/**.test.*'
#pull_request_review:
#types: [submitted, dismissed]
#pull_request_target:
#branches:
#- 'develop'
push:
branches:
- automation/6261-chanel-qa-approval-workflow
jobs:
check_for_qa_approval:
name: Requires QA approval
runs-on: ubuntu-latest
steps:
- name: Check QA approval
shell: bash
run: |
approvals=$(curl --request GET \
--url https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews?per_page=100 \
--header 'Authorization: ${{ secrets.GITHUB_TOKEN }}' \
--header 'Content-Type: application/json' |
jq -c '[map(select(.state == "APPROVED")) | .[] .user.login]')
echo "${{secrets.GH_ACTIONS_PAT}}" >> token.txt
gh auth login --with-token < token.txt
required_approval_count=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/department-of-veterans-affairs/va-mobile-app/branches/develop/protection |
jq -c '.required_pull_request_reviews.required_approving_review_count')
echo "Approvers: $approvals"
qa_team_members=$(
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/orgs/department-of-veterans-affairs/teams/flagship-mobile-qa/members |
jq -c '[.[] | .login]'
)
echo "required approval count: $required_approval_count"
echo "QA team: $qa_team_members"
if [[ $(jq '. | length' <<< "$approvals") -gt $required_approval_count ]]
then
if [[ $(jq '[.[] | select(. | IN("timwright12", "rbontrager", "DJUltraTom", "TKDickson"))] | length' <<< "$approvals") -gt 0 ]]
then
echo 'This PR has QA approval to merge'
exit 0
else
echo 'This PR requires QA approval to merge'
exit 1
fi
else
echo 'This PR requires 2 approvals, including one QA and one engineerapprovals, before merging.'
exit 1
fi