add pre-condition on approved PR

This commit is contained in:
maurizio-cacace 2023-01-13 14:49:46 +01:00
parent 73e1953418
commit 55b146044e
No known key found for this signature in database
GPG Key ID: BC860F452395F645

View File

@ -8,9 +8,6 @@ on:
required: false
type: boolean
default: true
push:
branches:
- AAE-12046-pr-condition
pull_request:
types: [opened, synchronize, reopened]
branches:
@ -68,8 +65,37 @@ env:
DOCKER_REPOSITORY: "${{ secrets.DOCKER_REPOSITORY_DOMAIN }}/alfresco/demo-shell"
jobs:
setup:
check-if-pr-is-approved:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check if PR is approved
id: action
uses: kamatama41/get-pr-number-action@v0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Show the number
env:
GH_TOKEN: ${{ github.token }}
shell: bash
if: ${{ github.event_name != 'schedule' }}
run: |
echo "PR number is: ${{ steps.action.outputs.number }}"
prNumber=${{ steps.action.outputs.number }}
checkApproval=$(gh api /repos/Alfresco/alfresco-ng2-components/pulls/$prNumber/reviews | jq '.[] | select(.state == "APPROVED") | .user.login')
if [[ $checkApproval ]]; then
echo "PR approved"
else
echo "PR not approved yet"
exit 1
fi
setup:
# long timeout required when cache has to be recreated
timeout-minutes: 30
name: "Setup"